Hi Team
Hi Team.
So i have a VA that is assigned to a computer object. When this Boolean VA is ticked it kicks off a Workflow that has authorization around it. If then approved i need it to run the script below.
The issue i have is that i need to pass the computer name of the object having the box ticked. Now i thought i could get away with something like this but its not working. Is there something different i need to use for computer objects?
$devicename = $DirObj.get("samaccountname")
function AddSCCMDevice($Request) { # Get Quest ARS Computer Name $devicename = $DirObj.get("samaccountname") # Site configuration $SiteCode = "CODE-HERE" # Site code $ProviderMachineName = "FQDN-HERE" # SMS Provider machine name # Customizations $initParams = @{} #$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging #$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors # Do not change anything below this line # Import the ConfigurationManager.psd1 module if((Get-Module ConfigurationManager) -eq $null) { Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams } # Connect to the site's drive if it is not already present if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams } # Set the current location to be the site code. Set-Location "$($SiteCode):\" @initParams # Import the SCCM module Import-Module ConfigurationManager #$devicename=$env:COMPUTERNAME # Get the device object from SCCM $device = Get-CMDevice -Name $deviceName # Get the collection object from SCCM $collection = Get-CMDeviceCollection -Name "Collection-Name-HERE" # Add the device to the collection Add-CMDeviceCollectionDirectMembershipRule -Collection $collection -ResourceId $device.ResourceId }