0 votes

Hi Team,

I am getting my task via the following code and its working

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$taskName = "Azure VDI Start"

# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the task.
$container = $service.Backend.GetConfigurationContainerPath("ScheduledTasks")
$tasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $container
$taskPath = $tasksPathObj.CreateChildPath("CN=$taskName,CN=1 DEV,CN=zTest Area")
$task = $service.OpenObject($taskPath.ToString(), $null, $null, 0)

Now I want to change the attribute of OwnerServiceDnsHostName with this command

$task.Put("OwnerServiceDnsHostName","<servername>.<domains>.<tld>")
$task.SetInfo()

But getting this

Exception calling "SetInfo" with "0" argument(s): "The parameter is incorrect. "
At line:2 char:1
+ $task.SetInfo()
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DirectoryComException

Is this the wrong approach to update this setting via PowerShell?

ago by (2.0k points)

1 Answer

0 votes
ago by (304k points)

Hello,

The approach you are using is incorrect. Here is how the script should looks like (the Put method is not used at all).

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$taskName = "Azure VDI Start"

# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the task.
$container = $service.Backend.GetConfigurationContainerPath("ScheduledTasks")
$tasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $container
$taskPath = $tasksPathObj.CreateChildPath("CN=$taskName,CN=1 DEV,CN=zTest Area")
$task = $service.OpenObject($taskPath.ToString(), $null, $null, 0)

$task.OwnerServiceDnsHostName = "adaxes.company.com"
$task.SetInfo()

Related questions

0 votes
1 answer

For creating a computer object, we want to check if the entered CN is already used in our AD. And for that we want to use a powershell script. An other dot ... powershell script should be start before creating the computer object, right? Thanks for your help.

asked Jun 4, 2024 by KEME (80 points)
0 votes
1 answer

This script description says it can find the manager via FullName Distinguished name or Display name. Wondering if we can change it to use employeeID or SamAccountName.

asked Oct 24, 2022 by mightycabal (1.1k points)
0 votes
1 answer

Hey there, Our users manage their distrubution group members via Outlook. Using native AD tools, our service desk technicians are accustomed to having a checkbox underneath the 'Managed ... via Outlook to the new object (Group or User). Thanks in advance! Kirk

asked May 24, 2012 by Kirk (60 points)
0 votes
1 answer

We have a security initiative to disable the default Exchnage Online (EXO) PowerShell access for users, while retaining access for Admins. I would like to implement ... com/en-us/powershell/exchange/disable-access-to-exchange-online-powershell?view=exchange-ps

asked Mar 14 by Mark.Monaco (40 points)
0 votes
1 answer

This may sound a little convoluted, but I will try and explain. I'd like to have an operation require approval by a group. And if the initiator is a member of that group, I don ... into it at a new company. I've got to dust off some of the brain cells. Thanks.

asked Jul 17, 2024 by wd.swaters (40 points)
3,731 questions
3,409 answers
8,625 comments
550,196 users