Im trying to get this to work, the goal for me is to clean old code using linebreaks. How can I code the properties declaration to make it look like bellow?
#Propertes declaration
$properties = {
objectguid
Name
distinguishedName
samaccountName
mail
telephonenumber
mobile
title
l
department
buildingName
ExtensionAttribute10
roomNumber
manager
}
You can have line breaks after each comma, semikolon, opening parenthesis, curly braces or - if it’s really necessary - backticks. Another technique to make code better readable is splatting.
Also, just another tip, don’t put unnecessary comments in your code.
# properties declaration
$properties = ....
The variable is named “$properties” is sufficient with out the clutter of comments. Use comments to tell someone the purpose of something that isn’t obvious. For instance, Invoke-RestMethod uses TLS 1.0 by default and it’s being deprecated everywhere, so I put comments around [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 because you would have to look that up (most likely) to understand why that is there.
Thanks for reply and thanks for the tip I will follow your advice when asking questions here. (Im still a newbie, but have learnt a lot recent days. The code bellow is what I executed when i got the error. Any ideas why I get the error?
Get-ADUser : One or more properties are invalid.
Parameter name: objectguid Name distinguishedName samaccountName mail telephonenumber mobile title l department buildingName ExtensionAttribute10 roomNumber manager´