List AD Computers of specific OU with SSDs

Goozee, Dan 1 Reputation point
2021-01-18T18:21:40.907+00:00

Hi I was wondering if anyone can help. I am familiar to a degree of using the cmdlet Get-ADComputer to return all computers of a certain OU container i.e. like the following

Get-ADComputer -SearchBase "OU=Test Campus,OU=Workstations,OU=College,DC=internal,DC=college,DC=ac,DC=uk" -Filter 'OperatingSystem -like "Windows 10"' -Properties * |

Select -Property Name,operatingSystem |

Export AD Computer Report to CSV file

Export-CSV "C:\results.csv" -NoTypeInformation -Encoding UTF8

However I would like to also return all pc's that have SSD,s installed so was thinking whether I can incorporate the cmdlet Get-PhysicalDisk i.e. Get-PhysicalDisk | Select FriendlyName, MediaType

but not sure if the two cmdlets can be mixed. Does anyone know how I could do this. Would i need to provide a "For each" loop or something. I don't mind losing the windows 10 filter if it makes it simpler to do. I am very novice at this so more explanation the better. Any help much appreciated.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,547 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 111.1K Reputation points MVP
    2021-01-18T18:38:19.143+00:00

    You should work with a for-each loop to get this done. First get the computers from AD and get the disk details for each computer.
    But be aware for the 'Get-PhysicalDisk' you have to connect to each machine remotely to get the disk details (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-7.1). Instead of New-PSSession maybe Invoke-Command is an option as well (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.1)
    Also you have to deal with computers that are not reachable (not connected to the network, offline, ....) when the script is running. Otherwise New-PSSession or Invoke-Command will maybe throw an error.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.