This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to execute powershell commands inside ARS scripts

Hello,

I'm having issues with some powershell commands inside ARS script: I'm experiencing a very weird thing where my code doesn't get executed despite the debug log doesn't shows any error.

I'm attaching both my script and the debug log; i've also semplified the code so that just the essentials commands are left. The script basically does 3 things:

1. creates a local folder on a fixed path on the specified server
2. shares this folder on the root of the server
3. assigns the share to the newly created users.

function onPostCreate($Request) {

	$username = $Request.get("samaccountname")
	$server = $Request.get("edsva-servers")
	
	if (!$server) { 
		$server = 'S00V09951880'
	}
	
	$sharepath = '\\' + $server
	$localpath = 'D:\Users'
	
	# crea NT folder in path fisico
	New-Item -Name $username -ItemType Directory -Path $localpath
	
	# crea share
	net share "$username=$localpath\$username" "/GRANT:$username,CHANGE" "/GRANT:ITA\ITA data Manager,FULL"
	
	# assegna all'utente
	Set-QADUser $UserName -HomeDirectory "$sharepath\$username" -HomeDrive U: -proxy

}

WARNING: The names of some imported commands from the module 'ActiveRolesManagementShell' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
<-------------------------------------------------------------->
<----  New Debug Session  10/20/2016 11:21:21 AM ---->
<-------------------------------------------------------------->
<------------------- $Request  XML ------------------------>
 <CreateRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" dn="CN=TEST lino 5566,OU=Provisioning,OU=Users & Clients,OU=SECOP1,OU=BNLSEC,DC=ita,DC=net,DC=intra" xmlns="urn:schemas-quest-com:ActiveRolesServer">
  <Attributes>
    <Attribute name="displayName" operation="Replace" type="String">
      <Values>
        <Value>TEST lino 5566</Value>
      </Values>
    </Attribute>
    <Attribute name="employeeID" operation="Replace" type="String">
      <Values>
        <Value>5566</Value>
      </Values>
    </Attribute>
    <Attribute name="givenName" operation="Replace" type="String">
      <Values>
        <Value>lino</Value>
      </Values>
    </Attribute>
    <Attribute name="objectClass" operation="Replace" type="String">
      <Values>
        <Value>user</Value>
      </Values>
    </Attribute>
    <Attribute name="sAMAccountName" operation="Replace" type="String">
      <Values>
        <Value>5566</Value>
      </Values>
    </Attribute>
    <Attribute name="sn" operation="Replace" type="String">
      <Values>
        <Value>TEST</Value>
      </Values>
    </Attribute>
    <Attribute name="userPrincipalName" operation="Replace" type="String">
      <Values>
        <Value>TEST.lino.5566@ita.net.intra</Value>
      </Values>
    </Attribute>
    <Attribute name="userAccountControl" operation="Replace" type="Integer">
      <Values>
        <Value>512</Value>
      </Values>
    </Attribute>
    <Attribute name="pwdLastSet" operation="Replace" type="LargeInteger">
      <Values>
        <Value>0</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaPassword" operation="Replace" type="String" encrypted="true">
      <Values>
        <Value>**********</Value>
      </Values>
      <EncryptedValues>
        <Value>AQAAABGVTEKnt8tSzhNxpEvSKn6oF2yaAorjxRWL4WKsYBnl0kPTnpxg+sCptdcZcVyit9skEfiM
j/b9y2o23HXBqaSr5YLsN4k/BUt+1ZDiKSAfIGzxsDySfQkMwRz25Mgy6w==</Value>
      </EncryptedValues>
    </Attribute>
    <Attribute name="edsaNormalAccount" operation="Replace" type="Boolean">
      <Values>
        <Value>true</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaUPNPrefix" operation="Replace" type="String">
      <Values>
        <Value>TEST.lino.5566</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaUPNSuffix" operation="Replace" type="String">
      <Values>
        <Value>@ita.net.intra</Value>
      </Values>
    </Attribute>
    <Attribute name="edsva-OrgUnit" operation="Replace" type="String">
      <Values>
        <Value>ou=ATCENT,ou=RDVITA</Value>
      </Values>
    </Attribute>
    <Attribute name="edsva-Servers" operation="Replace" type="String">
      <Values>
        <Value>S00V09951880</Value>
      </Values>
    </Attribute>
    <Attribute name="edsvaUserMustChangePasswordAtNextLogon" operation="Replace" type="Boolean">
      <Values>
        <Value>true</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaCreateMsExchMailbox" operation="Replace" type="Boolean">
      <Values>
        <Value>false</Value>
      </Values>
    </Attribute>
    <Attribute name="objectSid" operation="Replace" type="OctetString">
      <Values>
        <Value base64="true">AQUAAAAAAAUVAAAAU2idkVBaWJX/Gztb5xIDAA==</Value>
      </Values>
    </Attribute>
  </Attributes>
  <Controls>
    <Control id="13">
      <Values>
        <Value>ROMS000IM102.ita.net.intra</Value>
      </Values>
    </Control>
    <Control id="AllowApproval">
      <Values>
        <Value>Check</Value>
      </Values>
    </Control>
  </Controls>
</CreateRequest> 
 <------------------- $Request  XML ------------------------>
Call:  Set-PSDebug -trace 2
DEBUG:    1+  >>>> s4b84b5cc-c810-4775-9d48-9c0c512dec8e 'onPostCreate' $Request
DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:   23+   >>>> &$args[0] $args[1]

DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:    1+ function onPostCreate($Request)  >>>> {

DEBUG:     ! CALL function 'onPostCreate'
DEBUG:    3+  >>>> $username = $Request.get("samaccountname")

 Call method '$Request.Get'
     Arguments list:
         [1] : Value=samaccountname : Type=System.String
  Call '[PowerShellAttribute].Value'
  Call '[PowerShellAttribute].Value'
DEBUG:     ! SET $username = '5566'.
DEBUG:    4+  >>>> $server = $Request.get("edsva-servers")

 Call method '$Request.Get'
     Arguments list:
         [1] : Value=edsva-servers : Type=System.String
  Call '[PowerShellAttribute].Value'
  Call '[PowerShellAttribute].Value'
DEBUG:     ! SET $server = 'S00V09951880'.
DEBUG:    6+ if ( >>>> !$server) { 

DEBUG:   10+  >>>> $sharepath = '\\' + $server

DEBUG:     ! SET $sharepath = '\\S00V09951880'.
DEBUG:   11+  >>>> $localpath = 'D:\Users'

DEBUG:     ! SET $localpath = 'D:\Users'.
DEBUG:   14+  >>>> New-Item -Name $username -ItemType Directory -Path $localpath

DEBUG:   17+  >>>> net share "$username=$localpath\$username" "/GRANT:$username,CHANGE" "/GRANT:ITA\ITA data Manager,FULL"

DEBUG:   20+  >>>> Set-QADUser $UserName -HomeDirectory "$sharepath\$username" -HomeDrive U: -proxy

DEBUG:   22+  >>>> }

<------------------- $Request  XML ------------------------>
 <CreateRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" dn="CN=TEST lino 5566,OU=Provisioning,OU=Users & Clients,OU=SECOP1,OU=BNLSEC,DC=ita,DC=net,DC=intra" xmlns="urn:schemas-quest-com:ActiveRolesServer">
  <Attributes>
    <Attribute name="displayName" operation="Replace" type="String">
      <Values>
        <Value>TEST lino 5566</Value>
      </Values>
    </Attribute>
    <Attribute name="employeeID" operation="Replace" type="String">
      <Values>
        <Value>5566</Value>
      </Values>
    </Attribute>
    <Attribute name="givenName" operation="Replace" type="String">
      <Values>
        <Value>lino</Value>
      </Values>
    </Attribute>
    <Attribute name="objectClass" operation="Replace" type="String">
      <Values>
        <Value>user</Value>
      </Values>
    </Attribute>
    <Attribute name="sAMAccountName" operation="Replace" type="String">
      <Values>
        <Value>5566</Value>
      </Values>
    </Attribute>
    <Attribute name="sn" operation="Replace" type="String">
      <Values>
        <Value>TEST</Value>
      </Values>
    </Attribute>
    <Attribute name="userPrincipalName" operation="Replace" type="String">
      <Values>
        <Value>TEST.lino.5566@ita.net.intra</Value>
      </Values>
    </Attribute>
    <Attribute name="userAccountControl" operation="Replace" type="Integer">
      <Values>
        <Value>512</Value>
      </Values>
    </Attribute>
    <Attribute name="pwdLastSet" operation="Replace" type="LargeInteger">
      <Values>
        <Value>0</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaPassword" operation="Replace" type="String" encrypted="true">
      <Values>
        <Value>**********</Value>
      </Values>
      <EncryptedValues>
        <Value>AQAAABGVTEKnt8tSzhNxpEvSKn6oF2yaAorjxRWL4WKsYBnlmAtfDUk2gHlbFnHWfidlVgamqcCg
aeg2LtDeRxLR6rEKNwbG3yBpmBsAl49gOK+umZJtnmYHVUr/MZ1T5VPdWA==</Value>
      </EncryptedValues>
    </Attribute>
    <Attribute name="edsaNormalAccount" operation="Replace" type="Boolean">
      <Values>
        <Value>true</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaUPNPrefix" operation="Replace" type="String">
      <Values>
        <Value>TEST.lino.5566</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaUPNSuffix" operation="Replace" type="String">
      <Values>
        <Value>@ita.net.intra</Value>
      </Values>
    </Attribute>
    <Attribute name="edsva-OrgUnit" operation="Replace" type="String">
      <Values>
        <Value>ou=ATCENT,ou=RDVITA</Value>
      </Values>
    </Attribute>
    <Attribute name="edsva-Servers" operation="Replace" type="String">
      <Values>
        <Value>S00V09951880</Value>
      </Values>
    </Attribute>
    <Attribute name="edsvaUserMustChangePasswordAtNextLogon" operation="Replace" type="Boolean">
      <Values>
        <Value>true</Value>
      </Values>
    </Attribute>
    <Attribute name="edsaCreateMsExchMailbox" operation="Replace" type="Boolean">
      <Values>
        <Value>false</Value>
      </Values>
    </Attribute>
    <Attribute name="objectSid" operation="Replace" type="OctetString">
      <Values>
        <Value base64="true">AQUAAAAAAAUVAAAAU2idkVBaWJX/Gztb5xIDAA==</Value>
      </Values>
    </Attribute>
  </Attributes>
  <Controls>
    <Control id="13">
      <Values>
        <Value>ROMS000IM102.ita.net.intra</Value>
      </Values>
    </Control>
    <Control id="AllowApproval">
      <Values>
        <Value>Check</Value>
      </Values>
    </Control>
  </Controls>
</CreateRequest> 
 <------------------- $Request  XML ------------------------>


For an unknown reason task 2 and 3 are not completed even though from the debug log it seems that they have been executed.

The weirdest thing is that, the same exact code, is working like a charm inside my lab, but not at customer site.

Could you provide some enlightenment?

Thank you in advance,
Andrea

  • If you wish, you can automate this process by using the available command line switches off the the installation media, as per this resource:

    Title: Command line options for the installation of Active Roles
    Solution Number: 185799
    URL: support.software.dell.com/.../185799
  • The AR 7.0 console (on the aforementioned workstations) is able to successfully connect to the AR 7.0 service (that I have just enabled in order to test). I think we have good connectivity. That said, the 'ActiveRolesManagementShell' is its own entity and can exist without ARS or AR at all so not sure where the port fits in here, esp. since it's the ARS 6.9 that it can no longer Connect-QADService. But I thank you for your interest and suggestions! I don't know that I'll be able to test any more today, but will review any future advice from everyone.

    On a final note, what/where is the latest 'ActiveRolesManagementShell' just to be sure we are using it. Thanks again.
  • If the Console can connect, the the port is fine, agreed. Sorry, missed that it was the ActiveRoles Server 6.9 Management Shell which was experiencing issues.

    With Active Roles 7.0, there is no longer a separate entry for the Management Shell. In the Control Panel under Programs and Features | Uninstall a Program, you will see "Active Roles" with a version of 7.0.2.2193 or higher.
  • Thanks Terrance. So, and apologies if this is obvious because I've not yet really investigated the new PowerShell parts... Is there a standalone installer for the 'ActiveRolesManagementShell' that I can distribute to the various non-AR servers? Thanks again.
  • No, there is no longer a standalone installer. You can run the installer with command-line option as I noted above. This can be run remotely using a tool such as Microsoft's psexec.