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

Parents
  • Thanks JQ.

    Still nothing obvious here, though - we're connecting to the (current Production) ARS6.9 host(s) after logging in with Domain\User to the workstation (and subsequently just running PowerShell console). Simple stuff that was working fine prior to installing AR7.0 on the workstation(s). I have not attempted to connect to the AR7.0 backend yet. In fact, that service is not running for 99.9% of the time as we are still doing pre-migration testing.

    Of course, we'd like the CMDLETS to work just fine with ARS6.9, as they had been as recently as last week.
Reply
  • Thanks JQ.

    Still nothing obvious here, though - we're connecting to the (current Production) ARS6.9 host(s) after logging in with Domain\User to the workstation (and subsequently just running PowerShell console). Simple stuff that was working fine prior to installing AR7.0 on the workstation(s). I have not attempted to connect to the AR7.0 backend yet. In fact, that service is not running for 99.9% of the time as we are still doing pre-migration testing.

    Of course, we'd like the CMDLETS to work just fine with ARS6.9, as they had been as recently as last week.
Children
No Data