{"id":130,"date":"2013-02-24T19:30:34","date_gmt":"2013-02-24T18:30:34","guid":{"rendered":"http:\/\/powerkjell.com\/?p=130"},"modified":"2013-02-24T19:30:34","modified_gmt":"2013-02-24T18:30:34","slug":"script-to-set-new-password-in-office-365","status":"publish","type":"post","link":"https:\/\/powerkjell.com\/?p=130","title":{"rendered":"Script to set new password in Office 365"},"content":{"rendered":"<p>The following script can be used to set new password in Office 365. Replace username and password of service account and save file as Set-Password.ps1.<\/p>\n<p>Set-Password.ps1 -UserPrincipalName [UserPrincipalName] -NewPassword [NewPassord]<\/p>\n<p>[powershell]<br \/>\nparam<br \/>\n(<br \/>\n   [parameter(Mandatory = $true)][string]$UserPrincipalName,<br \/>\n   [parameter(Mandatory = $true)][string]$NewPassword<br \/>\n)<\/p>\n<p>function Set-Password()<br \/>\n{<br \/>\n   # Connect to service<br \/>\n   $Username = &#8220;admin@mydomain.onmicrosoft.com&#8221;<br \/>\n   $Password = ConvertTo-SecureString &#8220;P@ssword&#8221; -AsPlainText -Force<br \/>\n   $Credentials = New-Object System.Management.Automation.PSCredential $Username,$Password<br \/>\n   Connect-MsolService -Credential $Credentials<\/p>\n<p>   # Reset password<br \/>\n   $pwd = ConvertTo-SecureString $NewPassword -AsPlainText -Force<br \/>\n   Set-MsolUserPassword -UserPrincipalName $UserPrincipalName -NewPassword $pwd -ForceChangePassword $false<br \/>\n}<\/p>\n<p>Set-Password -UserPrincipalName $UserPrincipalName -NewPassword $NewPassword<br \/>\n[\/powershell]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following script can be used to set new password in Office 365. Replace username and password of service account and save file as Set-Password.ps1. Set-Password.ps1 -UserPrincipalName [UserPrincipalName] -NewPassword [NewPassord] [powershell] param ( [parameter(Mandatory = $true)][string]$UserPrincipalName, [parameter(Mandatory = $true)][string]$NewPassword ) &hellip; <a href=\"https:\/\/powerkjell.com\/?p=130\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[6,17],"_links":{"self":[{"href":"https:\/\/powerkjell.com\/index.php?rest_route=\/wp\/v2\/posts\/130"}],"collection":[{"href":"https:\/\/powerkjell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/powerkjell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/powerkjell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/powerkjell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":2,"href":"https:\/\/powerkjell.com\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/powerkjell.com\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/powerkjell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/powerkjell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/powerkjell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}