Zehra
(Zehra)
November 24, 2022, 11:31am
1
Hello everyone,
I have two dynamic variables, I want to use invoke powershell activity as an anternative way of active directory acitivities how can I run this script in uipath invoke powershell activity?
Do you have any idea?
New-ADGroup -Name “variable1” -SamAccountName variable1 -GroupCategory Security -GroupScope Global -DisplayName “variable1” -Path “OU=HQ_Units,OU=Permission_Groups,OU=Groups,DC=asdf,DC=local” -Description “Test”
Add-AdGroupMember -Identity “variable1” –Members variable2
Add-ADPrincipalGroupMembership -Identity variable1 -MemberOf variable2
Set-ADGroup -Identity “variable1” -Replace @{extensionAttribute15=“123”}
Thanks in advance
Yoichi
(Yoichi)
November 24, 2022, 2:08pm
2
Hi,
How about to use string.format as the following.
First, create text file for the script as the followng
New-ADGroup -Name "{0}" -SamAccountName {0} -GroupCategory Security -GroupScope Global -DisplayName "{0}" -Path "OU=HQ_Units,OU=Permission_Groups,OU=Groups,DC=asdf,DC=local" -Description "Test"
Add-AdGroupMember -Identity {0} –Members {1}
Add-ADPrincipalGroupMembership -Identity variable1 -MemberOf {1}
Set-ADGroup -Identity "{0}" -Replace @{{extensionAttribute15="123"}}
Set {0} or {1} to replace content of variable. And escape { and } character like {{ and }}.
script.txt (383 Bytes)
Then use string.Format(strPsScript,{variable1,variable2})
as the following.
Regards,
ptrobot
November 24, 2022, 2:46pm
3
You can also use the PowerShellVariables property to pass your variables to the PS-script.
system
(system)
Closed
December 5, 2022, 6:30am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.