Jump to content

HD-Design

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by HD-Design

  1. Unfortunately as mentioned the accounts are not AAD accounts, they are local to the tool, I was just hoping looking at my code somebody may of had a better suggestion to automate the process. I will keep exploring on my side
  2. So I have somehow been landed with a project, that I've previously had zero input on, so would appreciate any assistance.. Our company tool has internal accounts for students to use when we deliver training, these accounts are local to the tool and not using SSO via AAD or anything (I suggested this as it would make things soooooo easy, but customer firewalls made this an issue so we've had to opt for local accounts). At the end of a weeks training, we would like the delivering member of staff to be able to click a button and reset all the student accounts. So far I've got a rudamentory internal website where they can enter Shard/Location (US or Europe) and which student orgs they want to reset. On submitting the form it will simulate hitting the forgot password button for all of these accounts, and it will deliver emails to then reset the passwords for all of these accounts. The gold-standard would be to actually reset the password (even if to a single value for all) without the need for the manual overhead with the solution as I have it today. [color=#0000FF][font=Consolas]function[/font][/color][color=#000000][font=Consolas] password-reset {[/font][/color][color=#000000][font=Consolas] [CmdletBinding()] [color=#0000ff]param[/color]( [Parameter()] [string] [color=#001188]$orgId[/color], [string] [color=#001188]$shard[/color], [string] [color=#001188]$name[/color], [string] [color=#001188]$studentemail[/color] ) [color=#001188]$session[/color] = New-Object Microsoft.PowerShell.Commands.WebRequestSession [color=#001188]$session[/color].UserAgent = [color=#a31515]"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36"[/color] [color=#0000ff]if[/color] ([color=#001188]$shard[/color] -eq [color=#a31515]'eu'[/color]) { [color=#001188]$strHeader[/color] = @{ [color=#a31515]"authority"[/color]=[color=#a31515]"login.domain.eu"[/color] [color=#a31515]"method"[/color]=[color=#a31515]"POST"[/color] [color=#a31515]"path"[/color]=[color=#a31515]"/user/reset-password"[/color] [color=#a31515]"scheme"[/color]=[color=#a31515]"https"[/color] [color=#a31515]"accept"[/color]=[color=#a31515]"*/*"[/color] [color=#a31515]"accept-encoding"[/color]=[color=#a31515]"gzip, deflate, br"[/color] [color=#a31515]"accept-language"[/color]=[color=#a31515]"en-US,en;q=0.9"[/color] [color=#a31515]"origin"[/color]=[color=#a31515]"https://app.domain.eu"[/color] [color=#a31515]"referer"[/color]=[color=#a31515]"https://app.domain.eu/"[/color] [color=#a31515]"sec-ch-ua"[/color]=[color=#a31515]"`" Not A;Brand`";v=`"99`", `"Chromium`";v=`"102`", `"Google Chrome`";v=`"102`""[/color] [color=#a31515]"sec-ch-ua-mobile"[/color]=[color=#a31515]"?0"[/color] [color=#a31515]"sec-ch-ua-platform"[/color]=[color=#a31515]"`"Windows`""[/color] [color=#a31515]"sec-fetch-dest"[/color]=[color=#a31515]"empty"[/color] [color=#a31515]"sec-fetch-mode"[/color]=[color=#a31515]"cors"[/color] [color=#a31515]"sec-fetch-site"[/color]=[color=#a31515]"same-site"[/color] } [color=#001188]$strBody[/color] = [color=#a31515]"{`"email`":`"[/color][color=#001188]$studentemail[/color][color=#a31515]`",`"setPasswordUrl`":`"https://app.domain.eu/password/reset`"}"[/color] Invoke-WebRequest -UseBasicParsing -Uri [color=#a31515]"https://login.domain.eu/user/reset-password"[/color] -Method [color=#a31515]"POST"[/color] -WebSession [color=#001188]$session[/color] -Headers [color=#001188]$strHeader[/color] -ContentType [color=#a31515]"application/json"[/color] -Body [color=#001188]$strBody[/color] } [color=#0000ff]else[/color] { [color=#001188]$strHeader[/color] = @{ [color=#a31515]"authority"[/color]=[color=#a31515]"login.domain.com"[/color] [color=#a31515]"method"[/color]=[color=#a31515]"POST"[/color] [color=#a31515]"path"[/color]=[color=#a31515]"/user/reset-password"[/color] [color=#a31515]"scheme"[/color]=[color=#a31515]"https"[/color] [color=#a31515]"accept"[/color]=[color=#a31515]"*/*"[/color] [color=#a31515]"accept-encoding"[/color]=[color=#a31515]"gzip, deflate, br"[/color] [color=#a31515]"accept-language"[/color]=[color=#a31515]"en-US,en;q=0.9"[/color] [color=#a31515]"origin"[/color]=[color=#a31515]"https://app.domain.com"[/color] [color=#a31515]"referer"[/color]=[color=#a31515]"https://app.domain.com/"[/color] [color=#a31515]"sec-ch-ua"[/color]=[color=#a31515]"`" Not A;Brand`";v=`"99`", `"Chromium`";v=`"102`", `"Google Chrome`";v=`"102`""[/color] [color=#a31515]"sec-ch-ua-mobile"[/color]=[color=#a31515]"?0"[/color] [color=#a31515]"sec-ch-ua-platform"[/color]=[color=#a31515]"`"Windows`""[/color] [color=#a31515]"sec-fetch-dest"[/color]=[color=#a31515]"empty"[/color] [color=#a31515]"sec-fetch-mode"[/color]=[color=#a31515]"cors"[/color] [color=#a31515]"sec-fetch-site"[/color]=[color=#a31515]"same-site"[/color] } [color=#001188]$strBody[/color] = [color=#a31515]"{`"email`":`"[/color][color=#001188]$studentemail[/color][color=#a31515]`",`"setPasswordUrl`":`"https://app.domain.com/password/reset`"}"[/color] Invoke-WebRequest -UseBasicParsing -Uri [color=#a31515]"https://login.domain.com/user/reset-password"[/color] -Method [color=#a31515]"POST"[/color] -WebSession [color=#001188]$session[/color] -Headers [color=#001188]$strHeader[/color] -ContentType [color=#a31515]"application/json"[/color] -Body [color=#001188]$strBody[/color]} } [/font][/color] any help at all to refine this solution would be greatly appreciated! Thanks! HD
×
×
  • Create New...