sherlock1
asked on
Powershell script to get computer information from all servers in an AD domain
Hi Experts,
I am using the below powershell script to get various server information from the local server and output to a CSV file but was wondering if it was possible to adapt to get the computer information for all servers (servers mostly running Windows server 2016) on an AD domain. Is this possible?
$computerSystem = Get-CimInstance CIM_ComputerSystem
$computerBIOS = Get-CimInstance CIM_BIOSElement
$computerOS = Get-CimInstance CIM_OperatingSystem
$computerCPU = Get-CimInstance CIM_Processor
$computerHDD = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$netadapter = Get-WmiObject win32_networkadapterconfig uration -Filter IPEnabled=TRUE -ComputerName $Computer
$Object = New-Object PSObject -Property @{
"Computer Name" = $computerSystem.Name
"Operating System" = $computerOS.caption + ", Service Pack: " + $computerOS.ServicePackMaj orVersion
"Manufacturer" = $computerSystem.Manufactur er
"Model" = $computerSystem.Model
"Serial Number" = $computerBIOS.SerialNumber
"CPU" = $computerCPU.Name
"HDD Capacity" = "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
"HDD Space" = "{0:P2}" -f ($computerHDD.FreeSpace/$c omputerHDD .Size) + " Free (" + "{0:N2}" -f ($computerHDD.FreeSpace/1G B) + "GB)"
"RAM" = "{0:N2}" -f ($computerSystem.TotalPhys icalMemory /1GB) + "GB"
"MAC Address" = $netadapter.MACAddress
"DHCP Enabled" = $netadapter.DHCPEnabled
"IP Address" = $netadapter.IPAddress
"Subnet Mask" = $netadapter.IPSubnet
"Defaul Gateway" = $netadapter.DefaultIPGatew ay
"Domain/Workgroup Name" = $netadapter.DNSDomain
"User logged In" = $computerSystem.UserName
"Last Reboot" = $computerOS.LastBootUpTime
}
$Object | Export-Csv c:\Temp\systeminfo.csv -NoTypeInformation
Thanks
I am using the below powershell script to get various server information from the local server and output to a CSV file but was wondering if it was possible to adapt to get the computer information for all servers (servers mostly running Windows server 2016) on an AD domain. Is this possible?
$computerSystem = Get-CimInstance CIM_ComputerSystem
$computerBIOS = Get-CimInstance CIM_BIOSElement
$computerOS = Get-CimInstance CIM_OperatingSystem
$computerCPU = Get-CimInstance CIM_Processor
$computerHDD = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$netadapter = Get-WmiObject win32_networkadapterconfig
$Object = New-Object PSObject -Property @{
"Computer Name" = $computerSystem.Name
"Operating System" = $computerOS.caption + ", Service Pack: " + $computerOS.ServicePackMaj
"Manufacturer" = $computerSystem.Manufactur
"Model" = $computerSystem.Model
"Serial Number" = $computerBIOS.SerialNumber
"CPU" = $computerCPU.Name
"HDD Capacity" = "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
"HDD Space" = "{0:P2}" -f ($computerHDD.FreeSpace/$c
"RAM" = "{0:N2}" -f ($computerSystem.TotalPhys
"MAC Address" = $netadapter.MACAddress
"DHCP Enabled" = $netadapter.DHCPEnabled
"IP Address" = $netadapter.IPAddress
"Subnet Mask" = $netadapter.IPSubnet
"Defaul Gateway" = $netadapter.DefaultIPGatew
"Domain/Workgroup Name" = $netadapter.DNSDomain
"User logged In" = $computerSystem.UserName
"Last Reboot" = $computerOS.LastBootUpTime
}
$Object | Export-Csv c:\Temp\systeminfo.csv -NoTypeInformation
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER