Not sure where the issue lies with this one, but i’m trying to design a little menu that will take an asset name and MAC address from a text field and add them to an SCCM device collection.
Using:
New-UDTextbox -id Asset -label “Asset Tag” -icon “arrow_circle_o_right”
New-UDTextbox -id MAC -label “MAC Address” -icon “arrow_circle_o_right”
New-UDButton -id "Submit" -Text "Submit" -onclick {
$asset = (Get-UDElement -id Asset).Attributes.value
$mac = (Get-UDElement -id MAC).Attributes.value
$collection = "collection ID"
Import-CMComputerInformation -computername $asset -macaddress $mac -collection $collection
}
Doesn’t work. I’ve checked using a UDToast and the variables are picking up values. Now the SCCM cmdlets need to be run from the CM Drive, so you need to specify this normally using Set-Location “CMDrive:”. Initially I thought that this could be the issue, but i’ve tried moving the Set-Location inside the -onclick event handler, but this also makes no difference.
I’ve also tried simpler cmdlets, just trying the basic Get-CMDevice -name $asset etc, and nothing is being returned. I’ve been able to interact with other systems (ie AD, I can get Get-ADComputer etc to return results from inside an event handler), it just seems to be SCCM that doesn’t.
Any help gratefully received