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.