Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update journey-step-3.md #11971

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,8 @@ Modify the **userId** variable of the script to match your environment (first li
```azurepowershell-interactive
$userId = "<UPN of the user>"

function Generate-RandomPassword{
[CmdletBinding()]
param (
[int]$Length = 64
)
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,.<>/?\|`~"
$random = New-Object System.Random
$password = ""
for ($i = 0; $i -lt $Length; $i++) {
$index = $random.Next(0, $chars.Length)
$password += $chars[$index]
}
return $password
}
$Password = (New-Guid).Guid
$Password

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Install-Module Microsoft.Graph -Scope CurrentUser
Expand All @@ -95,7 +83,7 @@ Connect-MgGraph -Scopes "UserAuthenticationMethod.ReadWrite.All" -NoWelcome
$passwordParams = @{
UserId = $userId
AuthenticationMethodId = "28c10230-6103-485e-b985-444c60001490"
NewPassword = Generate-RandomPassword
NewPassword = $Password
}

Reset-MgUserAuthenticationMethodPassword @passwordParams
Expand All @@ -106,22 +94,10 @@ A similar script can be used to reset the password against Active Directory. Mod
```PowerShell
$samAccountName = <sAMAccountName of the user>

function Generate-RandomPassword{
[CmdletBinding()]
param (
[int]$Length = 64
)
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{};:,.<>/?\|`~"
$random = New-Object System.Random
$password = ""
for ($i = 0; $i -lt $Length; $i++) {
$index = $random.Next(0, $chars.Length)
$password += $chars[$index]
}
return $password
}
$Password = (New-Guid).Guid
$Password

$NewPassword = ConvertTo-SecureString -String (Generate-RandomPassword) -AsPlainText -Force
$NewPassword = ConvertTo-SecureString -String ($Password) -AsPlainText -Force

Set-ADAccountPassword -identity $userId -NewPassword $NewPassword -Reset
```
Expand Down
Loading