Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Disable accounts based on search

$
0
0

I'm trying to automate disabled our vendor vpn accounts at the end of the week. so far I have:

Import-Module ActiveDirectory
$Enabledlist = Get-ADUser -Filter {enabled -eq "True"} -SearchBase "OU=Vendor,OU=site,DC=job,DC=state,DC=local" | Select-Object SamAccountName 
foreach($enabledAccount in $enabledList)
    {Disable-ADAccount -Identity $enabledAccount} 

Problem is:

Cannot convert value "@{SamAccountName=vendervpnaccount}" to type "Microsoft.ActiveDirectory.Management.ADAccount"
I'm not sure how to just get the samaccountname and not the @{samaccountname= with it.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



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