I am trying to perform something that is very similar to Excel. For example, the below script is what I have in PowerShell.
get-aduser -filter * -properties * |
sort-object name |
select Name, samaccountname,
@{Name="Manager";Expression={(get-aduser -property name $_.manager).name}},
mail, office, officephone, homephone, ipPhone, telephonenumber, department,
city, streetaddress,company, CanonicalName, description |
where-object { $_.manager -ne $null -and $_.office -notlike "*123456*"}
My goal:
Search the "notes" field in Active Directory for every employee.
If it contains:
a. Hello = Put this in a new column called "NEW" and combine the fields with special characters. Example: (Phone Number@Desktop;).
b. GoodBye = Put this in a new column called "NEW" and combine the fields with special characters. Example: (Phone Number@Laptop;).
c. Orange = Put this in a new column called "NEW" and combine the fields with special characters. Example: (Phone Number@Tablet;).
- If it doesn't contain any of the specified criteria, show up as a blank in the "NEW" field.
Phone Number = $_.MobilePhone
Desktop/Laptop/Tablet = Strings
I have more criteria, but this is what I would like to accomplish. I'm a total beginner to Powershell and I believe that I need a calculated property, but I am not sure how to piece this together.
If this is in Excel, this is what I would do:
=IF(A1="GoodBye","1234567890@Laptop;",IF(A1="Orange","1234567890@Tablet;",IF(A1="Hello","1234567890@Desktop","")))