Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Tuesday, March 8, 2016

powershell script to get the list of app installed in multiple servers

Requirements :

1 . Powershell v3


2. save the list of computers in a text file and place it in root drive 

C:\1\Computers.txt






Script 

####################################################

Function IEVersion {
$Prop = [ordered]@{}
$ComputerName = Cat C:\1\Computers.txt
$ErrorActionPreference = "Stop"
foreach ($computer in $ComputerName)
  {

Try {
$Syntax = GWMI win32_operatingsystem -cn $computer
$Prop.Computername = $Syntax.CSName
$Prop.OperatingSystem = $Syntax.Caption
$Prop.ServicePack = $Syntax.CSDVersion
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer")
$Prop.IEVersion = $Regkey.GetValue("Version")

New-Object PSObject -property $Prop
  }

  Catch
  {
 
  Add-Content "$computer is not reachable" -path $env:USERPROFILE\Desktop\UnreachableHosts.txt
  }
 }
}
#HTML Color Code
#http://technet.microsoft.com/en-us/librProp/ff730936.aspx
$a = "<!--mce:0-->"
IEVersion | ConvertTo-HTML -head $a -body "<H2> IE Version</H2>" |
Out-File $env:USERPROFILE\Desktop\DomainController.htm #HTML Output
Invoke-Item $env:USERPROFILE\Desktop\DomainController.htm





##########################################################
output


IE Version

ComputernameOperatingSystemServicePackIEVersion
TRAINER-PCMicrosoft Windows 7 UltimateService Pack 19.10.9200.17609





Sunday, February 28, 2016

Get bulk server cpu memoru disk usage using powershell script


Input :

Save the list of servers in >>>>>>>>>>>>       c:\servers.txt

Output :

Results will be saved at >>>>>>>>>>>>>>>    C:\new\report.csv


Powershell script
###############################################################

GC C:\Servers.txt | % {
$Comp = $_
If (Test-Connection $Comp -Quiet){
$Mem = GWMI -Class win32_operatingsystem -computername $COMP
New-Object PSObject -Property @{
Server = $Comp
"CPU usage" = "$((GWMI -ComputerName $COMP win32_processor | Measure-Object -property LoadPercentage -Average).Average) %"
"Memory usage" = "$("{0:N2}" -f ((($Mem.TotalVisibleMemorySize - $Mem.FreePhysicalMemory)*100)/ $Mem.TotalVisibleMemorySize)) %"
"Total FreeSpace" = "$("{0:N2}" -f ((Get-WmiObject -Class win32_Volume -ComputerName $COMP -Filter "DriveType = '3'" | Measure-Object -property FreeSpace -Sum).Sum /1GB)) GB"
}
 }
 Else{
 "" | Select @{N="Server";E={$Comp}},"CPU usage","Memory usage","Total FreeSpace"
 }
}| Select Server,"CPU usage","Memory usage","Total FreeSpace" |
Export-Csv C:\new\report.csv -nti


#######################################################################

Tuesday, April 7, 2015

power shell script to check cpu,disk space,memory usage for bulk servers

Instructions :


Create a text file that contains list of servers in c:\servers.txt ( You can create in some other location also )


Output --> C:\new\report.csv

You will not get the output If you don't have write or read access on the drive


#########################################

GC C:\Servers.txt | % {
$Comp = $_
If (Test-Connection $Comp -Quiet){
$Mem = GWMI -Class win32_operatingsystem -computername $COMP
New-Object PSObject -Property @{
Server = $Comp
"CPU usage" = "$((GWMI -ComputerName $COMP win32_processor | Measure-Object -property LoadPercentage -Average).Average) %"
"Memory usage" = "$("{0:N2}" -f ((($Mem.TotalVisibleMemorySize - $Mem.FreePhysicalMemory)*100)/ $Mem.TotalVisibleMemorySize)) %"
"Total FreeSpace" = "$("{0:N2}" -f ((Get-WmiObject -Class win32_Volume -ComputerName $COMP -Filter "DriveType = '3'" | Measure-Object -property FreeSpace -Sum).Sum /1GB)) GB"
}
 }
 Else{
 "" | Select @{N="Server";E={$Comp}},"CPU usage","Memory usage","Total FreeSpace"
 }
}| Select Server,"CPU usage","Memory usage","Total FreeSpace" |
Export-Csv C:\new\report.csv -nti





Get the script here ------------> Bulk server cpu memory disk space usage