Category: IT Knowledge Base Articles (Page 5 of 11)

Powershell Script to Collect Bitlocker Recovery Key

Create this powershell script:

# Ensure the BitLocker module is imported

Import-Module BitLocker

# Retrieve all BitLocker volumes

$bitLockerVolumes = Get-BitLockerVolume

# Iterate through each BitLocker-protected volume

foreach ($volume in $bitLockerVolumes) {

    $mountPoint = $volume.MountPoint

    $keyProtector = $volume.KeyProtector | Where-Object { $_.KeyProtectorType -eq ‘RecoveryPassword’ }

    $recoveryPassword = $keyProtector.RecoveryPassword

    if ($recoveryPassword) {

        Write-Output “Drive $mountPoint – Recovery Password: $recoveryPassword”

    } else {

        Write-Output “Drive $mountPoint does not have a recovery password protector.”

    }

}

Reveal Known WiFi Password via Command Line

To reveal the password for a known Wi-Fi network (SSID) in Windows 11 using the command line, follow these steps:

  1. Open Command Prompt as Administrator:
    • Click on the Start menu, type cmd or Command Prompt in the search bar.
    • Right-click on Command Prompt from the search results and select Run as administrator.
  2. List All Saved Wi-Fi Profiles:
    • In the Command Prompt window, type the following command and press Enter:sqlCopyEditnetsh wlan show profiles
    • This command will display a list of all Wi-Fi profiles that your computer has connected to previously.
  3. Display the Password for a Specific Wi-Fi Profile:
    • Identify the Wi-Fi profile name (SSID) for which you want to reveal the password from the list generated in the previous step.
    • Type the following command, replacing Your_SSID with the name of your Wi-Fi network, and press Enter:pgsqlCopyEditnetsh wlan show profile name="Your_SSID" key=clear
    • In the output, scroll to the Security settings section.
    • Locate the line labeled Key Content; the value next to it is the Wi-Fi password.

Example: If your Wi-Fi network name is HomeNetwork, the command would be:

pgsqlCopyEditnetsh wlan show profile name="HomeNetwork" key=clear

The output will display information about the profile, and under Security settings, you’ll find:

yamlCopyEditSecurity settings:
    ...
    Key Content            : [Your Wi-Fi Password]

Note: Ensure you have administrative privileges to execute these commands. This method works for Wi-Fi networks that your computer has previously connected to and saved.

Symbolic Link

For a symbolic link for Scan to SMB setup. Needs Administrator privilege in Command

Replace File paths within quotes to help reduce SMB jumps. First file path is directory you want Windows

to lie about where the SCANS folder actually is.

mklink /D “C:\Users\Ultrex IT\OneDrive – Ultrex\IT\SCANS” “C:\SCANS”

Fixing a windows cloned drive that you need to expand the main partition, but can’t

This video is pretty well perfect for this task:

If you’ve already cloned the drive, but now you’ve got wasted extra space, but you can’t extend the partition because there’s a windows recovery partition in the way. The video linked walks you through it perfectly.

Here’s how you fix that:

command line:

reagentc /disable

diskpart

list partition

select partition x

detail partition

delete partition override

Re-create the Recovery Partition

list partition

select partition x

set id=

gpt attributes=

list volume

select volume y

remove letter=y

exit

reagentc /enable

Note: x=disk or partition number, y=volume letter.

%WINDIR%\system32\sysprep\sysprep.exe

To return to oobe without resetting and rebooting automatically

Return to OOBE without Resetting CMD

Can’t be done remotely

Open CMD as Admin

>Cd sysprep

>sysprep /oobe

To return to oobe and reboot automatically without resetting

Return to OOBE without Resetting CMD

CAN be done remotely (has so far worked with either a saved wifi connection or when connected to ethernet)

Open CMD as Admin

>Cd sysprep

>sysprep /oobe /rebootReturn to OOBE in windows

Powershell Windows Activation

Updated command for Windows 10/11 as of 2/20/26 –

Run Powershell as an administrator, copy and paste the code below and hit enter.  Windows should activate using Option 1 for most Windows OS’s, but use TSForge Option if you need to license a Server install. This can also be used to push through an office install.

NOTE: Only use this at the approval of a supervisor. If we overuse this without the correct licensing as its foundation, we risk a customer being set up for issues in an audit. This command is to be used when Windows fails to activate a license that we know its supposed to activate, often after a Return to OOBE for Entra/Intune Enrollment.

Use the one below for most reliable resolution of get.activated.win in Ultrex Office

iex (curl.exe -s –doh-url https://1.1.1.1/dns-query https://get.activated.win | Out-String)

The following are alternative options if the one above doesn’t work (use your mobile hotspot if needed) –

Option 1:

irm https://get.activated.win | iex

Option 2:

irm https://massgrave.dev/get | iex

If none of the options above work, use this code in powershell administrator mode instead:

if ($ExecutionContext.SessionState.LanguageMode.value__ -ne 0) {
    $ExecutionContext.SessionState.LanguageMode
    Write-Host "Windows PowerShell is not running in Full Language Mode."
    Write-Host "Help - https://massgrave.dev/fix_powershell" -ForegroundColor White -BackgroundColor Blue
    return
}

function Check3rdAV {
    $avList = Get-CimInstance -Namespace root\SecurityCenter2 -Class AntiVirusProduct | Where-Object { $_.displayName -notlike '*windows*' } | Select-Object -ExpandProperty displayName
    if ($avList) {
        Write-Host '3rd party Antivirus might be blocking the script - ' -ForegroundColor White -BackgroundColor Blue -NoNewline
        Write-Host " $($avList -join ', ')" -ForegroundColor DarkRed -BackgroundColor White
    }
}

function CheckFile { 
    param ([string]$FilePath) 
    if (-not (Test-Path $FilePath)) { 
        Check3rdAV
        Write-Host "Failed to create MAS file in temp folder, aborting!"
        Write-Host "Help - https://massgrave.dev/troubleshoot" -ForegroundColor White -BackgroundColor Blue
        throw 
    } 
}

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$URLs = @(
    'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/37ec96504a2983a5801c43e975ab78c8f9315d2a/MAS/All-In-One-Version-KL/MAS_AIO.cmd',
    'https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?path=/MAS/All-In-One-Version-KL/MAS_AIO.cmd&versionType=Commit&version=37ec96504a2983a5801c43e975ab78c8f9315d2a',
    'https://git.activated.win/massgrave/Microsoft-Activation-Scripts/raw/commit/37ec96504a2983a5801c43e975ab78c8f9315d2a/MAS/All-In-One-Version-KL/MAS_AIO.cmd'
)

foreach ($URL in $URLs | Sort-Object { Get-Random }) {
    try { $response = Invoke-WebRequest -Uri $URL -UseBasicParsing; break } catch {}
}

if (-not $response) {
    Check3rdAV
    Write-Host "Failed to retrieve MAS from any of the available repositories, aborting!"
    Write-Host "Help - https://massgrave.dev/troubleshoot" -ForegroundColor White -BackgroundColor Blue
    return
}

# Verify script integrity
$releaseHash = '49CE81C583C69AC739890D2DFBB908BDD67B862702DAAEBCD2D38F1DDCEE863D'
$stream = New-Object IO.MemoryStream
$writer = New-Object IO.StreamWriter $stream
$writer.Write($response)
$writer.Flush()
$stream.Position = 0
$hash = [BitConverter]::ToString([Security.Cryptography.SHA256]::Create().ComputeHash($stream)) -replace '-'
if ($hash -ne $releaseHash) {
    Write-Warning "Hash ($hash) mismatch, aborting!`nReport this issue at https://massgrave.dev/troubleshoot"
    $response = $null
    return
}

# Check for AutoRun registry which may create issues with CMD
$paths = "HKCU:\SOFTWARE\Microsoft\Command Processor", "HKLM:\SOFTWARE\Microsoft\Command Processor"
foreach ($path in $paths) { 
    if (Get-ItemProperty -Path $path -Name "Autorun" -ErrorAction SilentlyContinue) { 
        Write-Warning "Autorun registry found, CMD may crash! `nManually copy-paste the below command to fix...`nRemove-ItemProperty -Path '$path' -Name 'Autorun'"
    } 
}

$rand = [Guid]::NewGuid().Guid
$isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -match 'S-1-5-32-544')
$FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MAS_$rand.cmd" } else { "$env:USERPROFILE\AppData\Local\Temp\MAS_$rand.cmd" }
Set-Content -Path $FilePath -Value "@::: $rand `r`n$response"
CheckFile $FilePath

$env:ComSpec = "$env:SystemRoot\system32\cmd.exe"
Start-Process -FilePath $env:ComSpec -ArgumentList "/c """"$FilePath"" $args""" -Wait
CheckFile $FilePath

$FilePaths = @("$env:SystemRoot\Temp\MAS*.cmd", "$env:USERPROFILE\AppData\Local\Temp\MAS*.cmd")
foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item }

Once powershell is successful, a command prompt window will open and give you multiple options.  Select option 1 if you only need the version of  Windows activated.  If you need to change the product type, there should be an option to do so in the same command dialogue box

Domain Joined Device Adding a Local Administrator

New-LocalUser -Name "ADMIN" -Password (ConvertTo-SecureString "ADMIN" -AsPlainText -Force) -UserPrincipalName "ADMIN" -Description "Administrator Account" -AccountNeverExpires $true
Add-LocalGrouMember -Group "Administrators" -Member "ADMIN"
When trying to get administrative access to a domain joined device that is not on the network and does not recognize domain admin credentials and we don't know local admin credentials, through Atera, go to Manage -> PowerShell -> As System and you can either type in "create administrator "ADMIN" with password "ADMIN" or copy and paste the command above.

This process is still in testing until further tests have been ran.

Command Line/Powershell create users, block password change

Add User and Set Password to Never Expire (especially for Scanning User)

Net user Scanning Scanning12 /add

Make PW never expire (Powershell most reliable to work, all will still break with big windows updates)

  • Command Line Admin option 1 (deprecating): WMIC USERACCOUNT where Name=’Scanning’ set PasswordExpires=False
  • Command Line Admin option 2 (sometimes an option): net user “Scanning” /expires:never
  • Powershell Admin (most reliable): Set-LocalUser -Name “Scanning” -PasswordNeverExpires $true

Command line Add Users and Scans Folder w sharing, Password Never Expires

Add User and Set Password to Never Expire (especially for Scanning User)

Net user Scanning Scanning12 /add


Make PW never expire

  • Command Line Admin: WMIC USERACCOUNT where Name=’Scanning’ set PasswordExpires=False
  • Powershell Admin: Set-LocalUser -Name “Scanning” -PasswordNeverExpires $true

Commands to Setup and Share Scans Folder through CLI

Mkdir C:\SCANS (creates Scans folder)

Dir C:\ (to confirm Scans folder creation)

Cd c:\scans (to select scans folder)

Net share scans=c:\scans /grant:Scanning,full (to grant read/write permissions with Scanning User – confirm permissions if needed)

« Older posts Newer posts »

© 2026 Ultrex Staff

Theme by Anders NorenUp ↑