Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $users = Get-ADUser -Filter * -SearchBase "OU=All Users,DC=Contoso,DC=com" -Properties GivenName,Surname,Description,UserPrincipalName,telephoneNumber
- $apikey = "supersecretapikey"
- $url = "snipeurl"
- $password = "INSERT_LONG_PASSWORD_HERE"
- foreach ($user in $users)
- {
- $snipeUser = Get-User -search $user.UserPrincipalName -url $url -apiKey $apikey
- if(([string]::IsNullOrEmpty($snipeUser))) {
- New-User -firstName $user.GivenName -lastName $user.Surname -userName $user.UserPrincipalName -password $password -password_confirmation $password -jobTitle $user.Description -phone $user.telephoneNumber -email $user.UserPrincipalName -url $url -apiKey $apikey
- }
- Else {
- Set-User -id $snipeUser.id -first_name $user.GivenName -last_name $user.Surname -jobtitle $user.Description -email $user.UserPrincipalName -phone $user.telephoneNumber -url $url -apiKey $apikey
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment