Updating field information for a number of users
This example demonstrates how to update the Employer
field, or any other field, for a large number of users. This can be done manually for a small number of users, but it is very useful if you automate it for a large user base.
In this scenario, we need a user list for the users who want to change or update the field information. A user list can be in any file format that the PowerShell console understands, preferably a text file with one username per line:
Import-Module SMLets # Class declaration for Users $Class = Get-SCSMClass –Name Microsoft.AD.User $UList = Get-Content 'C:\users_list.txt' foreach ($U in $UList) { Get-SCSMObject -Class $Class -filter "username -eq $U" | Set-SCSMObject -Property Company -Value "CompanyName" Get-SCSMObject -Class $Class -filter "username -eq $U" | Format-Table username, company }
For each user in the user list, this script block will display the updated information of the company, along...