Hi Frederick,
Thank you very much for your scripts, they seem to be exactly what I am after. I've tried to run the Device script with PowerShell as shown below but I get the following error and I can't understand what the problem is so any help would be greatly
appreciated!
If I am supposed to enter the name of the device as a parameter somewhere please let me know where it needs to go?
Sorry, I am new to all of this stuff!
Thanks,
Bonemister
Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> param (
>> [string]$device
>> )
>>
PS C:\Windows\system32> Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")
PS C:\Windows\system32> $SiteCode = Get-PSDrive -PSProvider CMSITE
PS C:\Windows\system32> $SiteServer = $SiteCode.Root
PS C:\Windows\system32> set-location ($SiteCode.name+":")
PS WTR:\>
PS WTR:\> $DID = (Get-CMDevice -Name $device).ResourceID
Get-CMDevice : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that
is not null or empty, and then try the command again.
At line:1 char:28
+ $DID = (Get-CMDevice -Name $device).ResourceID
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-CMDevice], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ConfigurationManagement.Cmdlets.Collections.C
ommands.GetDeviceCommand
PS WTR:\> $Collections = (Get-WmiObject -Class sms_fullcollectionmembership -Namespace root\sms\site_$SiteCode -Filter "
ResourceID = '$($DID)'").CollectionID
PS WTR:\> foreach ($Collection in $Collections)
>> {
>> Get-CMDeviceCollection -CollectionId $Collection | select Name, CollectionID
>>