Initial Commit
This commit is contained in:
parent
544753774a
commit
806c8a06c2
2 changed files with 100 additions and 2 deletions
80
Get-WirelessPassword.ps1
Normal file
80
Get-WirelessPassword.ps1
Normal file
|
@ -0,0 +1,80 @@
|
|||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Gathers the SSID/Passwords for known wireless networks for a given computer or set of computers.
|
||||
|
||||
.DESCRIPTION
|
||||
Gathers the SSID/Passwords for known wireless networks for a given computer or set of computers.
|
||||
Given a provided SSID, you can get the password for an individual SSID.
|
||||
|
||||
.PARAMETER SSID
|
||||
Defines the specific SSID to determine the password. If not provided, the script will gather all SSIDs.
|
||||
|
||||
.PARAMETER ComputerName
|
||||
Specifies the computers on which the command runs. The default is the local computer.
|
||||
|
||||
.PARAMETER Credential
|
||||
Credential that should be used to connect to a remote machine.
|
||||
|
||||
.NOTES
|
||||
Version: 1.0
|
||||
Author: Tyler Hale
|
||||
Creation Date: 2022.05.26
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory = $false)]
|
||||
[ValidateNotNull()]
|
||||
$SSID,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[ValidateScript( {Test-Connection $_ -Count 2})]
|
||||
[alias('Cn')]
|
||||
[string[]]
|
||||
$ComputerName = $env:COMPUTERNAME,
|
||||
[Parameter(Mandatory=$false, ValueFromPipeline=$true)]
|
||||
[ValidateNotNull()]
|
||||
[System.Management.Automation.PSCredential]
|
||||
[System.Management.Automation.Credential()]
|
||||
$Credential = [System.Management.Automation.PSCredential]::Empty
|
||||
)
|
||||
|
||||
############################################# [Internal Processing] ##############################################
|
||||
|
||||
<# Build Remote Parameters #>
|
||||
# Reference by appending @RemoteParameters to a command
|
||||
|
||||
$RemoteParameters = @{}
|
||||
|
||||
if ($ComputerName -ne $env:COMPUTERNAME) {
|
||||
Write-Verbose "Adding $ComputerName to Remote Parameters splat variable"
|
||||
$RemoteParameters['ComputerName'] = $ComputerName
|
||||
}
|
||||
|
||||
if ($Credential -ne [System.Management.Automation.PSCredential]::Empty) {
|
||||
Write-Verbose "Adding provided credentials to Remote Parameters splat variable"
|
||||
$RemoteParameters['Credential'] = $Credential
|
||||
}
|
||||
|
||||
################################################## [Execution] ###################################################
|
||||
|
||||
if ($null -ne $SSID) {
|
||||
Invoke-Command @RemoteParameters -ArgumentList $SSID -ScriptBlock {
|
||||
$Password = (netsh wlan show profiles name=$($args[0]) key=clear | Select-String 'Key Content') -replace ".*:\s+"
|
||||
if ("" -ne $Password) {
|
||||
[PSCustomObject][ordered]@{"SSID"=$args[0];"Password"=$Password}
|
||||
}
|
||||
else {
|
||||
Write-Host "Profile $($args[0]) is not found on the system."
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Invoke-Command @RemoteParameters -ScriptBlock {
|
||||
foreach($SSID in ((netsh wlan show profiles | Select-String ': ' ) -replace ".*:\s+")) {
|
||||
$Password = (netsh wlan show profiles name=$SSID key=clear | Select-String 'Key Content') -replace ".*:\s+"
|
||||
[PSCustomObject][ordered]@{"SSID"=$SSID;"Password"=$Password}
|
||||
}
|
||||
}
|
||||
}
|
20
README.md
20
README.md
|
@ -1,3 +1,21 @@
|
|||
# get-wirelesspassword
|
||||
# Get-WirelessPassword
|
||||
|
||||
Gathers the SSID/Passwords for known wireless networks for a given computer or set of computers.
|
||||
|
||||
## Variables
|
||||
|
||||
| Variable | Required | Default | Choices | Description |
|
||||
| ------------ | -------- | ------------- | ------- | ------------------------------------------------------------- |
|
||||
| Path | No | All SSIDs | | Defines the specific SSID to determine the password. |
|
||||
| ComputerName | No | Local Machine | | Specifies the computers on which the command runs |
|
||||
| Credential | No | Running User | | Credential that should be used to connect to a remote machine |
|
||||
|
||||
## Example
|
||||
|
||||
```powershell
|
||||
.\Get-WirelessPassword.ps1
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
See LICENSE file for full license information.
|
||||
|
|
Loading…
Reference in a new issue