Advertisement
Guest User

4

a guest
Feb 10th, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1.     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2.     <html>
  3.     <head>
  4.     <title>Reset O365 User Password</title>
  5.     </head>
  6.     <body>
  7.     <?php
  8.     // If no submit is posted display the form.
  9.     if(!isset($_POST["submit"]))
  10.     {
  11.     ?>
  12.         <form name="Password-Reset" id="Password-Reset" action="password-reset.php" method="post" />
  13.             Username(E-Mail): <input type="text" name="o365username" id="o365username" /><br />
  14.             New Password: <input type="text" name="o365password" id="o365password" /><br />
  15.             <input type="submit" name="submit" id="submit" value="Reset" />
  16.         </form>
  17.     <?php  
  18.     }
  19.     // ElseIf submit was pressed, check if all of the required variables have a value:
  20.     elseif((!empty($_POST["o365username"])) OR (!empty($_POST["o365password"])))
  21.     {
  22.         // Get the variables submitted by POST to pass them to the PowerShell script:
  23.         $o365username = $_POST["o365username"];
  24.         $o365password = $_POST["o365password"];
  25.            
  26.         // Path to the PowerShell script. Remember double backslashes:
  27.         $psScriptPath = "C:\\powershell\\PasswordReset\\PasswordReset.ps1";
  28.    
  29.         // Execute the PowerShell script, passing the parameters:
  30.         echo '<img src=\"images\processing.gif\" border=\"0\"></ br>';
  31.         $psquery = shell_exec("powershell -command $psScriptPath -username '$o365username' -password '$o365password'< NUL");
  32.         echo "</ hr></ br>";
  33.         echo $psquery; 
  34.     }
  35.     // Else Submit posted without all required fields being filled out
  36.     else
  37.     {
  38.         echo "Sorry, you did not complete all required fields. Please go back and try again.";
  39.     }
  40.     ?>
  41.     </body>
  42.     </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement