Tuesday, October 31, 2017

Powershell Script to get Clustername from Ad Computer Object


We can get Adcomputerobjects from Ad..But how to filter or list out  the Cluster name from Ad.

Below is a simple Powershell Script to get Cluster name(Alias) from Ad Computer Object


Get-ADComputer -Filter 'servicePrincipalName -Like "*MSClusterVirtualServer*"' -Properties Name, LastLogonTimestamp, pwdLastSet, servicePrincipalName| Select Name, @{n='LastLogonTimestamp';e={[DateTime]::FromFileTime($_.LastLogonTimestamp)}}, @{n='pwdLastSet';e={[DateTime]::FromFileTime($_.pwdLastSet)}}, DistinguishedName 



Regards
Bijesh

PowerShell command to get Print queue from print server



Get-WMIObject Win32_printer -Computername <servername> |Format-Table -AutoSize

Monday, October 30, 2017

Powershell script to reboot multiple servers







$Servers=Get-Content c:\users\Bijesh\ServerRebootlist.txt

$cred = Get-Credential "localHost\administrator"

ForEach ($Server in $servers)
{
write-Host $Server

 #Restart-Computer -ComputerName $Server -Force -ThrottleLimit 10 -Credential $cred

}


Regards
Bijesh

Sunday, October 29, 2017

How to Combine two HTML File to single

How to Combine two HTML File to single

          There are some scenarios  where we need to combine multiple html out put single ,How do we do that ...Powers shell have simple command to get this done,lets see who to achieve that



Html File one -> C:\Users\Bijesh\Desktop\HTML-Report1.html

Html Fine Two ->C:\Users\Bijesh\Desktop\HTML-Report.html


Here is the One line Powershell command to combine two Html files ...


(Get-Content "C:\Users\Bijesh\Desktop\HTML-Report1.html") + (Get-Content "C:\Users\Bijesh\Desktop\HTML-Report.html") | Set-Content "C:\Users\Bijesh\Desktop\Combined.html"

Regards
Bijesh

Batch Script to Restart service on multiple servers

Batch Script to Restart service on multiple servers


The Following example is to Restart the service "wuauserv"  on list of servers

Save the below Line to a batch file (.CMD  or .Bat) and execute to restart the service


@echo off
for /f %%i in (C:\Users\Bijesh\Desktop\Server.txt) do sc \\%%i start "wuauserv"


Regards
Bijesh