When I use this command and view the variables in Visual Studio Code, I only see 8 variables as opposed to all of them, even though I specified "*" for properties. Interestingly, under the "property count" property of each object, it states 103. I don't know why I can't see them though. Why is this?
When trying to filter the items with the Where clause, based on the PasswordNeverExpires propery, it does indeed filter the objects, but it isn't giving me what I want. When I go through the results manually and do a Get-ADUser lookup in Powershell ISE on the filtered objects, it states that the PasswordNeverExpires is set to True, even though I specified that I only wanted objects where that property was false.
I feel like the first problem is related to the second one so I thought I'd include it. This must be something simple that I'm missing because I've been debugging this for an hour. Can someone please explain to me why I can't see the properties of the object that I specified and why the Where clause is seemingly doing the opposite of what I want?
Even when you specify -Properties * the cmdlet will show you the default output. If you like to see all attributes you should use eiteher a Format-List * or a Select-Object -Property *.
If you like to check for true or false you will have to use the Powershell default variables$true and $false.
BTW: to format code in this forum you should use the code tag button of post editor (pre). Thanks
[quote quote=162557]Even when you specify -Properties * the cmdlet will show you the default output. If you like to see all attributes you should use eiteher a Format-List * or a Select-Object -Property *.
BTW: to format code in this forum you should use the code tag button of post editor (pre). Thanks
[/quote]
Thank you for the response. Piping the output to Select-Object -Property * worked. If it did indeed have the values for those properties stored in $test, even if they weren’t clearly visible, they must have been somewhere that I can find within the Variables window pane in Visual Studio Code. If not, then how would piping to Select-Object work if it didn’t have the properties to begin with? Could you explain more in-depth why simply specifying the properties within the Get-ADUSer command was not enough?
I have fixed the code tag above, sorry about that.
[quote quote=162617]That’s strange. Just running $test should show all the properties. I’m not sure what you’re doing in Vscode.
[/quote]
The code I have above is the entire script, just those two lines. The other commentor indicated that it may just be the way Powershell is. What happens when you run those two lines that I have?
[/quote]
You have to set a breakpoint and temporarily halt code execution. Set the breakpoint at the first statement, then step over and look at the $test variable in the Variables window
You have to set a breakpoint and temporarily halt code execution. Set the breakpoint at the first statement, then step over and look at the $test variable in the Variables window
I don’t get it. Things like Step Over, Step Into, Step Out, Continue, Stop Debugging, and Restart Debugging under Debug are greyed out, and I set a breakpoint and picked Start Debugging.
why this approach? we always want to filter as far left as possible, your initial approach you literally return every user object in that ou, as well as every property possible. You should only retrieve the exact properties you require, and you should filter as early in the pipeline as possible.
That’s so weird. I didn’t think it was even retrieving the variables successfully since the Where clause wasn’t working, but as the above poster stated, I need to use $true or $false, I can’t specify it as a string.
[quote quote=162684][/quote]
I know it’s best to specify only the needed properties. I only specified “*” for testing purposes.