Alex
asked on
Sanity check on code please
Guys,
Can I please get a sanity check on this?
Thanks
Alex
Can I please get a sanity check on this?
# Import AD Module
Import-Module ActiveDirectory
#enter CSV location
$users = Import-Csv -Path 'C:\temp\source.csv'
# Loop through CSV and update users if the exist in CSV file
foreach ($user in $users) {
#Search in specified OU and Update existing attributes
Set-ADUser -identity $user -EmployeeID $user.EmployeeID -Department $User.'Department Name' -Company $user.Company -Office $user.Office -title $user.'Job Title'
Thanks
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It is a hash table, with the argument names as keys, and the value for the argument as value ([switch] types can be handled like bool).
The "splatting" part comes when passing it to the function/cmdlet: note the @ (instead of the $) in front of the variable name containing the hash table.
And as you can see above, you can combine splatting and regular arguments without problem.
splatting is usually easier to read/handle than line continuation with a near-invisible backtick.
The "splatting" part comes when passing it to the function/cmdlet: note the @ (instead of the $) in front of the variable name containing the hash table.
And as you can see above, you can combine splatting and regular arguments without problem.
splatting is usually easier to read/handle than line continuation with a near-invisible backtick.
ASKER
That's pretty. Very pretty. oBdA you need to let me buy you a few drinks.... :-)
splatting creates a hash table of key/value pairs which you can chain onto a cmdlet.
ASKER