Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Set-ADUser cmdlet and -AccountExpirationDate

$
0
0

$Expires = $null
Set-ADUser -Identity $DN -AccountExpirationDate $Expires

Error I get:  "Set-ADUser : Missing an argument for parameter 'AccountExpirationDate'. Specify a parameter of type 'System.Nullable`1[System.DateTime]' and try again."

But if I do the following it works: 

Set-ADUser -Identity $DN -AccountExpirationDate $null

-----------------------------

So the reason this is an issue is that I have a number of switch and if statements that set the variables above that line of code and then I run one long Set-ADUser command.  I didn't want to create entirely separate commands for one situation and use another for the other.

So how can I pass a NULL variable that I create?  Or of course any other solution or suggestion...


Find this post helpful? Does this post answer your question? Be sure to mark it appropriately to help others find answers to their searches.


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>