set-qaduser error

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jadamski
Posts: 32
Last visit: Tue Sep 22, 2009 12:32 am

set-qaduser error

Post by jadamski »

I'm having a bit of trouble with using Set-QADUser and don't understand what I'm doing wrong.

If I run
Get-QADUser -SiteLimit 13000 | where {$_.Company} | % {Write-Host $_.name $_.company}

I get the group of AD records I want to blank out the Company field. When I try to do the set-qaduser I get an error:
Set-QADUser : Value does not fall within the expected range. At line 1 char 68

Char 68 is the space between Set_QADUser & $_

Code I'm using:

$cred = Get-Credential
Get-QADUser -SiteLimit 13000 | where {$_.Company} | % {Set-QADUser $_ -Company '' -Credential $cred}
User avatar
jadamski
Posts: 32
Last visit: Tue Sep 22, 2009 12:32 am

set-qaduser error

Post by jadamski »

I'm having a bit of trouble with using Set-QADUser and don't understand what I'm doing wrong.

If I run
Get-QADUser -SiteLimit 13000 | where {$_.Company} | % {Write-Host $_.name $_.company}

I get the group of AD records I want to blank out the Company field. When I try to do the set-qaduser I get an error:
Set-QADUser : Value does not fall within the expected range. At line 1 char 68

Char 68 is the space between Set_QADUser & $_

Code I'm using:

$cred = Get-Credential
Get-QADUser -SiteLimit 13000 | where {$_.Company} | % {Set-QADUser $_ -Company '' -Credential $cred}
User avatar
ikkarus
Posts: 9
Last visit: Fri May 23, 2008 11:01 pm

set-qaduser error

Post by ikkarus »

I am not trying to hi-jack the thread, but I am a little confused about something what does the:
| where {$_.Company} | do ?

I am thinking it is a compare but to what? is it saying where company has a value?

jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

set-qaduser error

Post by jvierra »

The $_.Company is clearly an error in coding as teh "weher" cmdlet can't take a null filter argument. If the arg is not nul it acts as if the "where" cmdlet is not there as it will pass everything down the pipe.

If teh value is NULL it will throw a terminating error.

The error is being caused by a null value being passed as "$_" to teh Set cmdlet. The $_ is at position 68 in the line.
This topic is 15 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked