Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Active user script not running

$
0
0

(New to power shell and not much familiar with concepts, need help on this!!)

I  tried to write the below script which should give the list of active users along with the properties described in $ADUserProperties function. All those active users should not have "Resources and shared mailbox" in their CN. 

 

$ADUserProperties = @(`

"department",

"DisplayName",

"title",

"AccountExpires",

"pwdlastset",

"lastLogon",

"whenCreated",

"Description",

"Mail",

"ScriptPath",

"homeDirectory",

"homeDrive",

"Company",

"CN",

"DistinguishedName"

"extensionAttribute1",

"extensionAttribute2",

"extensionAttribute3",

"extensionAttribute4",

"extensionAttribute5",

"extensionAttribute6",

"extensionAttribute7",

"extensionAttribute8",

"extensionAttribute9",

"extensionAttribute10",

"extensionAttribute11",

"extensionAttribute12",

"extensionAttribute13",

"extensionAttribute14",

"extensionAttribute15"

)

 

$SelectADUserProperties = @(`

"department",

"DisplayName",

"title",

"AccountExpires",

"pwdlastset",

"lastLogon",

"whenCreated",

"Description",

"Mail",

"ScriptPath",

"homeDirectory",

"homeDrive",

"Company",

"CN",

"DistinguishedName"

"extensionAttribute1",

"extensionAttribute2",

"extensionAttribute3",

"extensionAttribute4",

"extensionAttribute5",

"extensionAttribute6",

"extensionAttribute7",

"extensionAttribute8",

"extensionAttribute9",

"extensionAttribute10",

"extensionAttribute11",

"extensionAttribute12",

"extensionAttribute13",

"extensionAttribute14",

"extensionAttribute15"

)

 

Get-ADUser -searchbase “ou=Users,ou=MG,dc=domainname,dc=local” -Filter {Enabled -eq $True} | Where-object {$_.DistinguishedName -notlike "*OU=Resources and Shared mailboxes*"} -Properties $ADUserProperties  | `

select $SelectADUserProperties |export-csv "C:\Users\admbharti.gupta\Activeusers.csv" -NoTypeInformation -Encoding Unicode

 

When i am trying to run the above script it is throwing the below error:

Where-Object : A parameter cannot be found that matches parameter name 'Properties'.

At C:\Users\admbharti.gupta\Active users test.ps1:67 char:161

+ ... d mailboxes*"} -Properties $ADUserProperties  | `

+                    ~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Where-Object], ParameterBindingException

    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.WhereObjectCommand

 

 

Please suggest the necessary changes needs to be made in this script. Thanks in advance.

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles