Friday 6 November 2015

How to shutdown Multilple computers using Powershell

$computers = Get-Content "C:\computers.txt"

$offline =@()

foreach ($computer in $computers)



{

if (Test-Connection $computer -Count 3 -ea 0) {

Stop-Computer -ComputerName $computers



}

else {

$offline+= "$computer not reachable"



}}

Wednesday 29 July 2015

How to get Total installed memory on remote systems and export to csv


$computers= Get-Content -Path C:\servers.txt

$info=@()

foreach($computer in $computers){
$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "root\CIMV2" -computername $computer

foreach ($objItem in $colItems){
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)
$res = "" | select Computer,Memory
$res.computer = $computer
$res.Memory = $displayGB

$info +=$res

}
}
$info | Export-Csv c:\12.csv -NoTypeInformation

Tuesday 9 June 2015

Getting Disk space from Local system

If you want to get the list of disks and their use age use following script

get-wmiobject win32_logicaldisk -Filter "Drivetype=3" -ComputerName "localhost" | select systemName,deviceid,volumename,@{Name ="size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},
@{Name="Freespace(Gb)";Expression={"{0:N1}" -f($_.freespace/1gb)}} | Format-Table -AutoSize


Output will be

Powershell function to get theremote server IP details,Subnetmask,Gateway,DHCP Enabled status,DNS Servers,Wins and Macaddress

#Powershell function to get theremote server IP details,Subnetmask,Gateway,DHCP Enabled status,DNS Servers,Wins and Macaddress # use...