Wednesday, November 5, 2014

PING PONG :)


PING PONG :)
Below script will display the result on console.


 $PingMachines = Gc "C:\MachineList.txt"

ForEach($MachineName In $PingMachines)

{$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$MachineName'" |

Select-Object StatusCode

If ($PingStatus.StatusCode -eq 0)

{Write-Host $MachineName -Fore "Green"}

Else

{Write-Host $MachineName -Fore "Red"}}

 

Note: copy and paste the above script into text file and save it as Pingclient.ps1

 
Below script will out the file in .csv format.

 

Get-Content "C:\ MachineList.txt" | ForEach-Object {

if(Test-Connection -ComputerName $_ -Quiet -Count 1) {

New-Object -TypeName PSCustomObject -Property @{

VMName = $_

'Ping Status' = 'Ok'

}

} else {

New-Object -TypeName PSCustomObject -Property @{

VMName = $_

'Ping Status' = 'Powered OFF'

}

}

} | Export-Csv -Path "C:\PingStatus.csv" –NoTypeInformation

 

Note: copy and paste the above script into text file and save it as Pingclients.ps1

Friday, October 24, 2014

Get Installed Patches – Automatic Services on remote servers

Get Installed Patches and All Services which are set Automatic on remote servers

If you ever want to know what patches have been installed on remote clients/servers you would require the below powershell script.

Local Commands:

Get-WmiObject Win32_QuickFixEngineering| Where-Object {$_.installedon -match "MM/DD/YYYY"} | Select-object CSName,Description,HotFixID,InstalledOn,InstalledBy,Caption | Export-Csv -Path Report.csv -NoTypeInformation


Remote Commands:

FullList:-
Get-WmiObject Win32_QuickFixEngineering -Computer (Get-Content –path Servers.txt)|Select-object CSName,Description,HotFixID,InstalledOn,InstalledBy,Caption | Export-Csv -Path C:\Report.csv –NoTypeInformation
InstalledOn Date Report:-
Get-WmiObject Win32_QuickFixEngineering -Computer (Get-Content –path C:\Servers.txt) | Where-Object {$_.installedon -match "MM/DD/YYYY"} | Select-object CSName,Description,HotFixID,InstalledOn,InstalledBy,Caption | Export-Csv -Path Report.csv -NoTypeInformation

GreaterThan-Date Report:-
Get-WmiObject Win32_QuickFixEngineering -Computer (Get-Content –path C:\ Servers.txt) | Where-Object {$_.installedon -GT "MM/DD/YYYY"} | Select-object CSName,Description,HotFixID,InstalledOn,InstalledBy,Caption | Export-Csv -Path Report.csv -NoTypeInformation

GT Sort by Date:
Get-WmiObject Win32_QuickFixEngineering -Computer (Get-Content –path C: \Servers.txt) | Where-Object {$_.installedon -GT "MM/DD/YYYY"} | Select-object CSName,Description,HotFixID,InstalledOn,InstalledBy,Caption | Sort-Object InstalledOn -Descending | Export-Csv -Path c:\Report.csv -NoTypeInformation

Check the Windows services are in “Running” states which are set to “Auto”.

Get-WmiObject Win32_Service -ComputerName (Get-content " Servers.txt") |where {($_.startmode -like "*auto*") -and ($_.state -notlike "*running*")}| select SystemName,DisplayName,Name,StartMode,State| Export-csv –path “C:\ Services_Report.csv” –NoTypeInformation