What logon scripts are in your environment
"`nMicrosoft" Get-ADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(scriptpath=*))" -Properties *| Format-Table Name, DistinguishedName, ScriptPath -AutoSize "`nAD provider" Get-ChildItem -Filter "(&(objectclass=user)(objectcategory=user)(scriptpath=*))" ` -Path Ad:\"DC=Manticore,DC=org" -Recurse | foreach { $user = [adsi]"LDAP://$($_.DistinguishedName)" $user | select @{N="Name"; E={$_.name}}, @{N="DistinguishedName"; E={$_.distinguishedname}}, @{N="LogonScript"; E={$_.scriptpath}} } | Format-Table -AutoSize "`nQuest" Get-QADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(scriptpath=*))" -IncludeAllProperties | Format-Table Name, DN, ScriptPath -AutoSize "`nScript" $root = [ADSI]"" $search = [adsisearcher]$root $search.Filter = "(&(objectclass=user)(objectcategory=user)(scriptpath=*))" $search.SizeLimit = 3000 $search.FindAll() | foreach { $user = $_.GetDirectoryEntry() $user | select @{N="Name"; E={$_.name}}, @{N="DistinguishedName"; E={$_.distinguishedname}}, @{N="LogonScript"; E={$_.scriptpath}} } | Format-Table -AutoSize
Standard search for any user that has the scriptpath attribute set and then display name, distinguished name and scriptpath (logon script name).
To search for a given logon script – change the search filter
"(&(objectclass=user)(objectcategory=user)(scriptpath=<logon_script_name>))"
To just get a list of active logon scripts change the Format-Table as shown below
Get-ADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(scriptpath=*))" -Properties *|
sort scriptpath | select ScriptPath -Unique