UCSD Powershell example to Create AD Computer Account

Version 7
    Task NameCreate netApp Account
    Description
    Prerequisites
    1. Tested on 5.3.1
    CategoryWorkflow
    ComponentsvSphere 5.x
    User Inputs

    Instructions for Regular Workflow Use:

    1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
    2. Unzip the file on your computer. Should end up with a .WFD file.
    3. Log in to UCS Director as a user that has "system-admin" privileges.
    4. Navigate to "Policies-->Orchestration" and click on "Import".
    5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
    6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    8. Click "Submit".
    9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

     

     

    Setting up a Windows 2008 R2 AD Server:

     

    Administrative tools -> server manager

         add role

    Screen Shot 2015-06-26 at 11.37.00 AM.png

     

    In DOS Window run

         dcpromo

              Create a new forest

              New Domain (baylor.local)

              Set AD Admin Password

     

     

    Installed Light Weight Directory services:

     

    Screen Shot 2015-06-28 at 6.26.46 PM.png

    Installed .NET 4.5

    Installed the UCSD PSA agent

     

    Execute commands in a PS window:

         Set-ExecutionPolicy unrestricted

         Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force

         winrm quickconfig


    The workflow:


    Screen Shot 2015-06-28 at 6.14.21 PM.png


    The workflow execution:


    Screen Shot 2015-06-28 at 6.14.42 PM.png


    The SR Variable resolution:


    Screen Shot 2015-06-28 at 6.15.54 PM.png

    The Poweshell task to build the script:


    Screen Shot 2015-06-28 at 6.46.05 PM.png


    The Powershell task to execute the script:


    Screen Shot 2015-06-28 at 6.46.32 PM.png


    The SR Log Run:


    Service Request ID: 5252

    Workflow Inputs:

    - VMName

     

     

    Jun 28, 2015 22:59:25 UTC Request submitted

    Jun 28, 2015 22:59:28 UTC Executing workflow item number 1

    Jun 28, 2015 22:59:28 UTC Completed workflow item number 1, with status Completed

    Jun 28, 2015 22:59:31 UTC Executing workflow item number 2

    Jun 28, 2015 22:59:31 UTC Trigger context executeWorkFlowStep called

    Jun 28, 2015 22:59:31 UTC Executing custom action BaylorPowerShellTest (Execute PowerShell Command)

    Jun 28, 2015 22:59:31 UTC Executing custom action BaylorPowerShellTest (Execute PowerShell Command)

    Jun 28, 2015 22:59:33 UTC Max wait time min milli seconds = 300000

    Jun 28, 2015 22:59:34 UTC executor finished.....true

    Jun 28, 2015 22:59:34 UTC Command Output: <?xml version='1.0'?><Objects />Command successful

    Jun 28, 2015 22:59:34 UTC

    Jun 28, 2015 22:59:34 UTC Command executed successfully.

    Jun 28, 2015 22:59:34 UTC <?xml version='1.0'?><Objects />Command successful

    Jun 28, 2015 22:59:36 UTC Task #1 (BaylorPowerShellTest (Execute PowerShell Command)) completed successfully in 4 seconds

    Jun 28, 2015 22:59:36 UTC Input/Output values for Task #1 (BaylorPowerShellTest (Execute PowerShell Command)):

    Jun 28, 2015 22:59:36 UTC [Local Input: Label = Power]

    Jun 28, 2015 22:59:36 UTC [Local Input: PowerShell Agent = 172.17.32.106]

    Jun 28, 2015 22:59:36 UTC [Local Input: Target Machine IP = 172.17.32.106]

    Jun 28, 2015 22:59:36 UTC [Local Input: User ID = administrator]

    Jun 28, 2015 22:59:36 UTC [Local Input: Password = **masked-value**]

    Jun 28, 2015 22:59:36 UTC [Local Input: Domain = baylor.local]

    Jun 28, 2015 22:59:36 UTC [Template Input:Commands/Script = echo 'Import-module activedirectory' > c:\\ad.ps1 echo 'New-ADComputer -Name ${VMName} -Path 'CN=Computers,DC=baylor,dc=local'' >> c:\\ad.ps1]

    Jun 28, 2015 22:59:36 UTC [Resolved Template Input: Commands/Script = echo 'Import-module activedirectory' > c:\ad.ps1 echo 'New-ADComputer -Name b3 -Path 'CN=Computers,DC=baylor,dc=local'' >> c:\ad.ps1]

    Jun 28, 2015 22:59:36 UTC [Local Input: Commands/Script = echo 'Import-module activedirectory' > c:\ad.ps1 echo 'New-ADComputer -Name b3 -Path 'CN=Computers,DC=baylor,dc=local'' >> c:\ad.ps1]

    Jun 28, 2015 22:59:36 UTC [Local Input: Maximum Wait Time = 5]

    Jun 28, 2015 22:59:36 UTC [Output: POWERSHELL_COMMAND_RESULT = <?xml version='1.0'?><Objects />Command successful]

    Jun 28, 2015 22:59:36 UTC Completed workflow item number 2, with status Completed

    Jun 28, 2015 22:59:37 UTC Executing workflow item number 3

    Jun 28, 2015 22:59:37 UTC Trigger context executeWorkFlowStep called

    Jun 28, 2015 22:59:37 UTC Executing custom action BaylorPowerShellTest (Execute PowerShell Command)

    Jun 28, 2015 22:59:37 UTC Executing custom action BaylorPowerShellTest (Execute PowerShell Command)

    Jun 28, 2015 22:59:40 UTC Max wait time min milli seconds = 300000

    Jun 28, 2015 22:59:42 UTC executor finished.....true

    Jun 28, 2015 22:59:42 UTC Command Output: <?xml version='1.0'?><Objects />Command successful

    Jun 28, 2015 22:59:42 UTC

    Jun 28, 2015 22:59:42 UTC Command executed successfully.

    Jun 28, 2015 22:59:42 UTC <?xml version='1.0'?><Objects />Command successful

    Jun 28, 2015 22:59:43 UTC Task #2 (BaylorPowerShellTest (Execute PowerShell Command)) completed successfully in 5 seconds

    Jun 28, 2015 22:59:43 UTC Input/Output values for Task #2 (BaylorPowerShellTest (Execute PowerShell Command)):

    Jun 28, 2015 22:59:43 UTC [Local Input: Label = Execute PowerShell]

    Jun 28, 2015 22:59:43 UTC [Local Input: PowerShell Agent = 172.17.32.106]

    Jun 28, 2015 22:59:43 UTC [Local Input: Target Machine IP = 172.17.32.106]

    Jun 28, 2015 22:59:43 UTC [Local Input: User ID = administrator]

    Jun 28, 2015 22:59:43 UTC [Local Input: Password = **masked-value**]

    Jun 28, 2015 22:59:43 UTC [Local Input: Domain = baylor.local]

    Jun 28, 2015 22:59:43 UTC [Local Input: Commands/Script = c:\\ad.ps1]

    Jun 28, 2015 22:59:43 UTC [Local Input: Maximum Wait Time = 5]

    Jun 28, 2015 22:59:43 UTC [Output: POWERSHELL_COMMAND_RESULT = <?xml version='1.0'?><Objects />Command successful]

    Jun 28, 2015 22:59:43 UTC Completed workflow item number 3, with status Completed

    Jun 28, 2015 22:59:43 UTC Executing workflow item number 4

    Jun 28, 2015 22:59:43 UTC Completed workflow item number 4, with status Completed

     

     

    The file that is created on the AD server:

     

    Screen Shot 2015-06-28 at 6.09.23 PM.png

     

    The content of the file:

     

    Screen Shot 2015-06-28 at 6.09.34 PM.png

     

    The Results:

     

    Screen Shot 2015-06-28 at 6.09.40 PM.png

     

    Side notes:

     

    See these articles for details on how to completely disable UAC: