none
Powershell script not reporting errors? RRS feed

  • Question

  • Hey Guys,

    I have a shell script I use to process old AD accounts that involves the following:

    Set an expiry date
    Entering text into description field
    Removing membership to security/distribution groups
    Listing those groups in the Notes field in the Telephones tab
    Moving AD account to another OU

    Occasionally the script won't run properly. Sometimes it will stop halfway through say after entering an expiry but before setting a description. Other times not at all.

    It's not a huge issue because re-running the script invariably processes correctly but the problem I'm running into is Powershell doesn't put out an error when this happens so I have no way of easily knowing when I need to run it again.

    It could just be bad programming on my part but my question is are there parts of the Set-ADUser command in Powershell that don't put out errors? Is there a log of these kept somewhere else? Or is it just a case of Powershell not liking having to process all those commands above in a single script?

    If I can find those I should be able to fix the problem I'm running into

    • Moved by Bill_Stewart Thursday, March 24, 2016 4:11 PM Unanswerable drive-by question
    Wednesday, February 17, 2016 1:25 AM

All replies

  • Manage all error conditions and write to a log.

    No.  There are no parts of Set-AdUser that don't "put out" errors.

    If you are running under the scheduler you will never see the errors.


    \_(ツ)_/

    Wednesday, February 17, 2016 1:44 AM
  • To clarify, what I was referring to "putting out" errors were things like

    Remove-ADGroupMember : Cannot validate argument on parameter
    or
    Get-ADUser : Cannot find an object with identity

    I don't get anything like that. It just runs through and prints the text for the script being complete.

    Still I'll try putting some Write-Host commands halfway through and see if they print out.

    Scheduling isn't an issue as the script requires manual input to work

    Thanks for the pointers though.

    Wednesday, February 17, 2016 3:01 AM