Quantcast
Channel: System Center CentralPowerShell via Run .Net Script activity issue – System Center Central
Viewing all articles
Browse latest Browse all 7

PowerShell via Run .Net Script activity issue

$
0
0

I’m trying to run a PS script in an Orchestrator runbook on a weekly basis that uses the search-adaccount cmdlet to find all the user accounts in our contractors OU that are expiring in 7 days, pipe that to the get-aduser cmdlet to retrieve some extended properties, pipe that to a format-table cmdlet so it’s nice and readable, and email the result to our tier 1 support group. I can run the script fine outside of Orchestrator, just not from within using the Run .Net Script activity.

First, the script:

search-adaccount -u -accountexpiring -searchbase ”ou=consultants, ou=users, ou=corporate, ou=sites, dc=domain, dc=com” -t “7″ | get-aduser -Properties DisplayName, AccountExpirationDate, Description | Format-Table DisplayName, AccountExpirationDate, Description

Running that in the activity throws an error that the “search-adaccount” cmdlet is unknown.

The first thing I found was that the Active Directory PS module didn’t exist on the Server 2012 R2 Orchestrator servers, so I fixed that and can run this script both from x64 and x86 PS windows on both of our SCO servers.

Tried again from the runbook but got the same result, so I added an “import-module activedirectory” line to the beginning of the script, but still get the same result.

What am I doing wrong?


Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images