I was wondering if you could tell me one thing, just playing with this in altiris and it works to add the device but I keep getting a popup that wants my username and password twice, what do I have wrong in here to get that not ask for them
$ComputerName = $env:computername
$ComputerDomain = 'OURdomain'
$FilterGuid = '{ac7209c6-1491-4edd-ab9c-bd00f2b14311}'
$AltirisFQDN = 'smp1-awh.ourdomain'
$AltirisUserName = 'ourdomain\mysuername'
$AltirisPassword = 'mypassword'
[securestring]$p = ConvertTo-SecureString $ppt -AsPlainText -Force
[pscredential]$Creds = New-Object System.Management.Automation.PSCredential ($u, $p)
$CollectionManagementService = New-WebServiceProxy -Uri "https://$AltirisFQDN/Altiris/ASDK.NS/CollectionManagementService.asmx" -Credential $Creds -ErrorAction Stop
$ResourceManagementService = New-WebServiceProxy -Uri "https://$AltirisFQDN/Altiris/ASDK.NS/ResourceManagementService.asmx" -Credential $Creds -ErrorAction Stop
try {
$ComputerSearch = @($ResourceManagementService.GetComputerByNameAndDomain($ComputerName,$ComputerDomain))
} catch {
$_
}
if ($ComputerSearch.count -eq 0) {
throw "Computer was not found."
} else {
try {
#remove from filter
#$CollectionManagementService.RemoveInclusions($FilterGuid,$ComputerSearch[0])
#add to filter
$CollectionManagementService.AddInclusions($FilterGuid,$ComputerSearch[0])
#update filter membership
$CollectionManagementService.UpdateCollections($FilterGuid)
} catch {
$_
}
}
Original Message:
Sent: 08-05-2021 02:56 PM
From: Benjamin Barker
Subject: Is this possible? Script to add device to filter
Tested on 8.5 ru4. You should just need to update the 6 variables up top and change it to HTTP if you're not using https
$ComputerName = 'computername'
$ComputerDomain = 'domain'
$FilterGuid = '620a51e9-71b6-4efa-b804-a4fc4b8733cb'
$AltirisFQDN = 'yourNS.FQDN.com'
$AltirisUserName = 'domain\username'
$AltirisPassword = 'accountPassword'
[securestring]$p = ConvertTo-SecureString $AltirisPassword -AsPlainText -Force
[pscredential]$Creds = New-Object System.Management.Automation.PSCredential ($AltirisUserName, $p)
$CollectionManagementService = New-WebServiceProxy -Uri "https://$AltirisFQDN/Altiris/ASDK.NS/CollectionManagementService.asmx" -Credential $Creds -ErrorAction Stop
$ResourceManagementService = New-WebServiceProxy -Uri "https://$AltirisFQDN/Altiris/ASDK.NS/ResourceManagementService.asmx" -Credential $Creds -ErrorAction Stop
try {
$ComputerSearch = @($ResourceManagementService.GetComputerByNameAndDomain($ComputerName,$ComputerDomain))
} catch {
$_
}
if ($ComputerSearch.count -eq 0) {
throw "Computer was not found."
} else {
try {
#remove from filter
#$CollectionManagementService.RemoveInclusions($FilterGuid,$ComputerSearch[0])
#add to filter
$CollectionManagementService.AddInclusions($FilterGuid,$ComputerSearch[0])
#update #update #update filter membership
$CollectionManagementService.UpdateCollections($FilterGuid)
} catch {
$_
}
}