Kelly Garcia
asked on
Powershell HashTables
HI,
I have this powershell script:
Get-qadcomputer kellytestmachine | select Name, OSName, OSServicePack, ComputerRole, dNSHostName
all the items that are selected, I want them to be a different name for the csv file.
so I tried this for test however it failed:
Get-qadcomputer kellytestmachine | select Name, OSName, @{n="OS Service Pack";e={"$_.OSServicePack "}}, ComputerRole, dNSHostName
Thank you in advance
I have this powershell script:
Get-qadcomputer kellytestmachine | select Name, OSName, OSServicePack, ComputerRole, dNSHostName
all the items that are selected, I want them to be a different name for the csv file.
so I tried this for test however it failed:
Get-qadcomputer kellytestmachine | select Name, OSName, @{n="OS Service Pack";e={"$_.OSServicePack
Thank you in advance
ASKER
is this a better way of writing the script?
$ServerName = "kellytestmachine", "kellytestmachine2"
foreach ($s in $serverName) {
$servinfo = @{
Name = Get-Qadcomputer $_ | select Name
OSName = Get-Qadcomputer $_ | select OsName
ServicePack = Get-Qadcomputer $_ | select OsServicePack
DiskSpace (GB) = Get-WmiObject win32_logicaldisk -ComputerName $_
#IPAddress = code
#MacAddress = code
#Server Roles and Features = code
}
} | Export-Csv serverinfo.csv -NoTypeInformation
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window