AD Account expiration date from custom powershell activity

VivekSattanatha
Mega Sage
Mega Sage

Hi All

Anyone able to set account expiration date from Orchestration? We are trying to set it from custom PowerShell activity but it is not working. Please find the below command we used.

find_real_file.png

Our Target host is MID Server, AD server and MID server both are on the same network. Even though the commands are not working, the activity is running for a long time without showing any error or success. I had to cancel the activity all the time. Do you find any issue in this command?

bawiskar

Regards,

Vivek

1 ACCEPTED SOLUTION

Hi All,



The issue is resolved now. I tried running MID Server service with the Credential which I am using in ServiceNow. After that, it worked.



Regards,


Vivek


View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vivek,



I used the below script for user1 as samaccountname


Set-ADAccountExpiration "user1" -DateTime "02/20/2017"



The date should be in this format


var termDate = month+'/'+day+'/'+year;



This has worked for me.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,



I have used the below command



Import-Module activedirectory


Set-ADAccountExpiration   "user"   -DateTime "08/08/2017"



But still I am getting the below error


find_real_file.png



Any Ideas?



Regards,


Vivek


Hi Vivek,



Just check on community or powershell specific error messages. I didn't face such type of issue.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Your error message mentions "insufficient access rights to perform the operation" - doesn't that indicate that the account running the PowerShell script may not have sufficient privileges...?