├── Adobe Registry ├── Adobe Cache.ps1 └── README.MD ├── DriverSmart └── Driver.ps1 ├── LICENSE ├── README.md ├── RemoteDesktop └── RemoteDesktop.ps1 ├── Ruckus ├── Ruckus.md ├── Ruckus.ps1 └── Virtual Smart Zone │ └── Ruckus-SmartZone.ps1 ├── SpiceWorks ├── README.MD └── SpiceWorks.ps1 ├── WorkHarderNotSmarter.code-workspace └── Yealink ├── Login-ToPhone.ps1 ├── README.MD └── Yealink.ps1 /Adobe Registry/Adobe Cache.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [BOOL]$Debug = $True #Print Debug Messages 3 | ) 4 | 5 | if($Debug -eq $True) 6 | { 7 | Write-Host "Debug Mode Active..." 8 | } 9 | 10 | #11.0 = CC2017 12.0 = CC2018 11 | $MediaCacheLocations = @( 12 | "HKCU:\Software\Adobe\Common 11.0\Media Cache" 13 | "HKCU:\Software\Adobe\Common 12.0\Media Cache" 14 | ) 15 | 16 | $BridgeCacheLocation = "HKCU:\Software\Adobe\Bridge CC 2018\Preferences" 17 | 18 | #What's Installed 19 | $FoundAdobe = $False #Is An Adobe Product Installed? 20 | $FoundAdobePath = "" #What Is It? 21 | 22 | ## 23 | # This ForEach Goes Through The List Of Supported Adobe Products And Uses A Flag System To Determine What Is Installed. 24 | ## 25 | $Path = "H:\\" 26 | foreach($Version in $MediaCacheLocations) 27 | { 28 | if(Test-Path $Version) #If Registry Path Exists We're Good To Edit. 29 | { 30 | if($Debug -eq $True) 31 | { 32 | Write-Host "Found: " $Version 33 | } 34 | if(Test-Path $Path) 35 | { 36 | Set-ItemProperty -Path $FoundAdobePath -Name "FolderPath" -Value $Path 37 | Set-ItemProperty -Path $FoundAdobePath -Name "DatabasePath" -Value $Path 38 | } 39 | } 40 | } 41 | 42 | if(Test-Path $BridgeCacheLocation) 43 | { 44 | Set-ItemProperty -Path $BridgeCacheLocation -Name "CacheDirectory" -Value $Path 45 | Set-ItemProperty -Path $BridgeCacheLocation -Name "CompactCacheOnExit" -Value ([byte[]](0x01)) 46 | } 47 | 48 | #Nothing Was Found, Close. 49 | if($FoundAdobe -eq $False) 50 | { 51 | if($Debug -eq $True) 52 | { 53 | Write-Host "No Adobe Products Were Found, Closing." 54 | } 55 | Exit 56 | } -------------------------------------------------------------------------------- /Adobe Registry/README.MD: -------------------------------------------------------------------------------- 1 | # Adobe 2 | 3 | This script isn't exactly SysAdmin material however in my environment it was needed to allow users to change their Media Cache Location for Adobe products in the CC2017 and CC2018 family, my guess is you need to add: 4 | 5 | `"HKCU:\Software\Adobe\Common 13.0\Media Cache"` 6 | 7 | For this script to work with Adobe CC2019, however we have not deployed that at my work as of yet, I will update the script if this is the case. 8 | 9 | You just need to change the `$Path` variable for this to work, make sure it's a valid directory or create it from within the script. 10 | 11 | #### Functionsrk 12 | N/A 13 | -------------------------------------------------------------------------------- /DriverSmart/Driver.ps1: -------------------------------------------------------------------------------- 1 | $ErrorCodes = @( 2 | "This device is working properly.", 3 | "This device is not configured correctly.", 4 | "Windows cannot load the driver for this device.", 5 | "The driver for this device might be corrupted, or your system may be running low on memory or other resources.", 6 | "This device is not working properly.One of its drivers or your registry might be corrupted.", 7 | "The driver for this device needs a resource that Windows cannot manage.", 8 | "The boot configuration for this device conflicts with other devices.", 9 | "Cannot filter.", 10 | "The driver loader for the device is missing.", 11 | "This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.", 12 | "This device cannot start.", 13 | "This device failed.", 14 | "This device cannot find enough free resources that it can use.", 15 | "Windows cannot verify this device's resources.", 16 | "This device cannot work properly until you restart your computer.", 17 | "This device is not working properly because there is probably a re-enumeration problem.", 18 | "Windows cannot identify all the resources this device uses.", 19 | "This device is asking for an unknown resource type.", 20 | "Reinstall the drivers for this device.", 21 | "Failure using the VxD loader.", 22 | "Your registry might be corrupted." 23 | ) 24 | 25 | Get-WmiObject Win32_PNPEntity | ForEach-Object { 26 | Write-Host "Device Name: "$_.Name 27 | Write-Host "Device ID: "$_.DeviceID 28 | if($_.ConfigManagerErrorCode -gt 20) { 29 | Write-Host "Device Status: Unknown" -NoNewline 30 | Write-Host " ("$_.ConfigManagerErrorCode")" -ForegroundColor Yellow 31 | continue; 32 | } 33 | if($_.ConfigManagerErrorCode -ne 0) { 34 | Write-Host "Device Status: "$ErrorCodes[$_.ConfigManagerErrorCode] -NoNewline 35 | Write-Host " ("$_.ConfigManagerErrorCode")" -ForegroundColor Red 36 | } 37 | else { 38 | Write-Host "Device Status: "$ErrorCodes[$_.ConfigManagerErrorCode] -NoNewline 39 | Write-Host " ("$_.ConfigManagerErrorCode")" -ForegroundColor Green 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Johnathon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Work Harder and Not Smarter 2 | 3 | All Work And No PowerShell Is Not Fun 4 | 5 | ![PowerShell All The Things](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT-500OZMmrgLXHlqPdfoLBcTWtOvtcWYs-tibDt7w04hmEwDH0) 6 | 7 | (Thanks to [Allie Brosh](http://hyperboleandahalf.blogspot.com) for the artwork) 8 | 9 | So, you've stumbled across my corner of the world, my motto is: "If it's working, break it". I'll publish most of my SysAdmin-ish PowerShell scripts that I use in my day to day job, if you have any requests for Office365/Ruckus/SpiceWorks or more features in my existing scripts let me know! If I can do it I'll do it 😁 10 | -------------------------------------------------------------------------------- /RemoteDesktop/RemoteDesktop.ps1: -------------------------------------------------------------------------------- 1 | #$SupportedPackageNames = @("Microsoft.RemoteDesktop","Microsoft.MicrosoftRemoteDesktopPreview") 2 | function New-RemoteDesktopGroup 3 | { 4 | param( 5 | [Parameter(Mandatory=$True)] 6 | [STRING]$GroupName, 7 | [SWITCH]$IsExpanded 8 | ) 9 | $TestGroup = "$($IsExpanded.IsPresent.ToString().ToLower())$($GroupName)" 10 | $TestGroup | Out-File "$($env:LOCALAPPDATA)\Packages\Microsoft.RemoteDesktop_8wekyb3d8bbwe\LocalState\RemoteDesktopData\groups\$(New-Guid).model" -NoNewline -Encoding utf8 11 | } 12 | 13 | function New-RemoteDesktopConnection 14 | { 15 | param( 16 | [Parameter(Mandatory=$True)] 17 | [STRING]$HostName, 18 | [STRING]$FriendlyName = $HostName 19 | ) 20 | $ConnectionBody = 'true100'+$FriendlyName+''+$HostName+'true' 21 | $FileName = [GUID]::NewGuid() 22 | $ConnectionBody | Out-File "$($env:LOCALAPPDATA)\Packages\Microsoft.RemoteDesktop_8wekyb3d8bbwe\LocalState\RemoteDesktopData\LocalWorkspace\connections\$($FileName).model" -Encoding utf8 -NoNewline 23 | } 24 | 25 | function New-RemoteDesktopThumbnail 26 | { 27 | param( 28 | [Parameter(Mandatory=$True)] 29 | [STRING]$HostName, 30 | [Parameter(Mandatory=$True)] 31 | [STRING]$ImagePath 32 | ) 33 | 34 | $FoundHost = $False 35 | $ConnectionFile = "" 36 | ForEach($Connection in Get-ChildItem "$($env:LOCALAPPDATA)\Packages\Microsoft.RemoteDesktop_8wekyb3d8bbwe\LocalState\RemoteDesktopData\LocalWorkspace\connections\") 37 | { 38 | [XML]$ParsedConnection = Get-Content "$($env:LOCALAPPDATA)\Packages\Microsoft.RemoteDesktop_8wekyb3d8bbwe\LocalState\RemoteDesktopData\LocalWorkspace\connections\$($Connection)" 39 | if($ParsedConnection.GetElementsByTagName("*")[0].'HostName'.ToLower() -eq $HostName.ToLower()) 40 | { 41 | $FoundHost = $True 42 | $ConnectionFile = $Connection 43 | } 44 | } 45 | if($FoundHost -eq $False) 46 | { 47 | Write-Error "Couldn't Find Connection File For $($HostName)" -ErrorAction Stop 48 | } 49 | 50 | New-Item -Path "$($env:LOCALAPPDATA)\Packages\Microsoft.RemoteDesktop_8wekyb3d8bbwe\LocalState\RemoteDesktopData\RemoteResourceThumbnails\$($ConnectionFile)" -Force 51 | $BaseImage = [CONVERT]::ToBase64String((get-content $ImagePath -encoding byte)) 52 | $ThumbnailBody = "$($BaseImage)" 53 | $ThumbnailBody | Out-File "$($env:LOCALAPPDATA)\Packages\Microsoft.RemoteDesktop_8wekyb3d8bbwe\LocalState\RemoteDesktopData\RemoteResourceThumbnails\$($ConnectionFile)"-Encoding utf8 -NoNewline 54 | } 55 | 56 | function Add-RemoteConnectionToGroup 57 | { 58 | param( 59 | [Parameter(Mandatory=$True)] 60 | [STRING]$ConnectionHostName, 61 | [Parameter(Mandatory=$True)] 62 | [STRING]$GroupName 63 | ) 64 | } -------------------------------------------------------------------------------- /Ruckus/Ruckus.md: -------------------------------------------------------------------------------- 1 | # Ruckus 2 | 3 | This PowerShell script will let you interact with ZoneDirector on a very basic level, I've only taken the time to figure out what areas that I use, it should be easy for you to expand on what I've already learnt through my time poking about using [Fiddler](HTTPS://www.telerik.com/fiddler). This was tested on Ruckus ZoneDirector version: *9.13.3.0 build 41.* I take no responsibility for any network outage that these scripts cause. 4 | 5 | ## Functions 6 | 7 | **Name**: `New-RuckusSession` 8 | 9 | **Description**: This will create a connection to Ruckus and **NEEDS** to be called before any other functions as it sets up global varibles used throughout the script. 10 | 11 | **Parameters**: 12 | * [*Mandatory*] Uri `String` 13 | This should be the URL that is used to get to the ZoneDirector Interface. 14 | E.G. `ruckus.Contoso.com/` 15 | Be sure to include the trailing slash. 16 | * Username `String` 17 | This should be the username of a user who has access to the ZoneDirector, it defaults to a value of `Admin`. 18 | * [*Mandatory*] Password `String` 19 | This is the password of the user that will be used to access the ZoneDirector Interface. 20 | * IgnoreCertificate `Switch` 21 | This switch should be used if you're ZoneDirector isn't using an SSL Certificate. 22 | 23 | ___ 24 | 25 | **Name**: `Get-ManagedAPs` 26 | 27 | **Description**: This will return a list of all APs registered inside Ruckus' ZoneDirector. 28 | 29 | **Parameters**: 30 | 31 | * ApGroup `Int` 32 | This parameter is for showing APs that aren't in the default (`0`) group. 33 | 34 | ___ 35 | 36 | **Name**: `Get-APEvent` 37 | 38 | **Description**: This will show a list of all AP Events similar to Ruckus' event log on the admin interface. 39 | 40 | **Parameters**: 41 | * Ap `Unkown` 42 | I couldn't work this out, but made it a param incase someone does 43 | * StartFrom `Int` 44 | This is used for setting the start index so you can start pulling logs from that location onwards. 45 | * Count `Int` 46 | This is used to determine how many log messages you're wanting to pull down, it has a default value of `15` 47 | 48 | ___ 49 | 50 | **Name**: `Ban-Client` 51 | 52 | **Description**: This bans the specified Mac Address; use caution as this command will block access for the specified Mac Address until you unban them. 53 | 54 | **Parameters**: 55 | * MacAddress `String` 56 | This needs to be a valid Mac Address. 57 | 58 | ___ 59 | 60 | **Name**: Unban-Client 61 | 62 | **Description**: This will unban the specified Mac Address, it does the reverse of `Ban-Client` 63 | 64 | **Parameters**: 65 | * MacAddress `String` 66 | This needs to be a valid Mac Address 67 | 68 | ___ 69 | 70 | **Name**: Kick-Client 71 | 72 | **Description**: This will temporarily kick a client from the network, take note the client is welcome to rejoin whenever it wants, it is only useful for debugging. 73 | 74 | **Parameters**: 75 | * MacAddress `String` 76 | This needs to be a valid Mac Address 77 | 78 | ___ 79 | 80 | **Name**: Get-ActiveClients 81 | 82 | **Description**: This will show you all connected clients to all your APs with some helpful information about them such as the Mac of the connected AP and the client's Mac Address. 83 | 84 | **Parameters**: 85 | * Count `Int` 86 | This defaults to 15 but can be changed to any number, it will return this many clients. 87 | -------------------------------------------------------------------------------- /Ruckus/Ruckus.ps1: -------------------------------------------------------------------------------- 1 | #Default Is Admin 2 | $RuckusUsername = "" 3 | #Ruckus Password 4 | $RuckusPassword = "" 5 | #Ruckus URL 6 | $RuckusLoginPage = "" 7 | #Ruckus Session 8 | $RuckusSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession 9 | 10 | 11 | function Get-ActiveClients 12 | { 13 | [CmdletBinding()] 14 | #Get 15 Active Clients By Default 15 | param( 16 | [INT]$Count = 15 17 | ) 18 | 19 | #Login, Must Call New-RuckusSession First! 20 | LoginToRuckus 21 | 22 | #Grab Active Clients 23 | $Clients = Invoke-RestMethod ($Global:RuckusLoginPage + 'admin/_cmdstat.jsp') -WebSession $RuckusSession -Method POST -Body "​" 24 | $Clients.'ajax-response'.response.'apstamgr-stat'.client | Format-Table 25 | } 26 | 27 | function Kick-Client 28 | { 29 | [CmdletBinding()] 30 | param( 31 | [Parameter(Mandatory=$True)] 32 | [STRING]$MacAddress 33 | ) 34 | 35 | #Make Sure It's A Valid Mac Address 36 | isValidMac $MacAddress 37 | 38 | #Login, Must Call New-RuckusSession First! 39 | LoginToRuckus 40 | 41 | #Kick Client 42 | Write-Host "Kicking: $($MacAddress)" 43 | $Request = Invoke-RestMethod ($Global:RuckusLoginPage+'/admin/_cmdstat.jsp') -WebSession $RuckusSession -Method POST -Body "" 44 | } 45 | 46 | function Ban-Client 47 | { 48 | [CmdletBinding()] 49 | param( 50 | [STRING]$MacAddress 51 | ) 52 | 53 | #Make Sure It's A Valid Mac Address 54 | isValidMac $MacAddress 55 | 56 | #Login, Must Call New-RuckusSession First! 57 | LoginToRuckus 58 | 59 | #Ban Client 60 | Write-Host "Banning: $($MacAddress)" 61 | Invoke-RestMethod ($Global:RuckusLoginPage+'/admin/_cmdstat.jsp') -WebSession $RuckusSession -Method POST -Body "" | Out-Null 62 | } 63 | 64 | function Unban-Client 65 | { 66 | [CmdletBinding()] 67 | param( 68 | [STRING]$MacAddress 69 | ) 70 | 71 | isValidMac $MacAddress 72 | 73 | #Login, Must Call New-RuckusSession First! 74 | LoginToRuckus 75 | 76 | $Request = Invoke-RestMethod ($Global:RuckusLoginPage+'/admin/_conf.jsp') -WebSession $RuckusSession -Method Post -Body '' 77 | $FoundMacAddress = $false 78 | foreach($Node in $Request.'ajax-response'.response.'acl-list'.acl.deny) 79 | { 80 | if($Node.'mac' -eq "$($MacAddress)") { 81 | $FoundMacAddress = $true 82 | $Node.ParentNode.RemoveChild($Node) | Out-Null 83 | $Request.Save("$($env:TEMP)\UnBanClients.xml") 84 | } 85 | } 86 | if($FoundMacAddress -eq $false) { 87 | Write-Error "Mac address not found in block list." 88 | return 89 | } 90 | [XML]$UpdatedList = Get-Content "$($env:TEMP)\UnBanClients.xml" 91 | Invoke-RestMethod ($Global:RuckusLoginPage+'/admin/_conf.jsp') -WebSession $RuckusSession -Method Post -Body "$($UpdatedList.'ajax-response'.response.'acl-list'.acl.InnerXml | Out-String)" 92 | Remove-Item "$($env:TEMP)\UnBanClients.xml" -Force 93 | } 94 | 95 | function Get-APEvent 96 | { 97 | [CmdletBinding()] 98 | param( 99 | [String]$Ap = "*", 100 | [Int]$StartFrom = 0, 101 | [Int]$Count = 15 102 | ) 103 | 104 | #Login, Must Call New-RuckusSession First! 105 | LoginToRuckus 106 | 107 | #Grab Active Clients 108 | $Clients = Invoke-RestMethod ($Global:RuckusLoginPage + 'admin/_cmdstat.jsp') -WebSession $RuckusSession -Method POST -Body "" 109 | $Clients.'ajax-response'.response.response.xevent.lmsg 110 | 111 | } 112 | 113 | function Get-ManagedAPs 114 | { 115 | [CmdletBinding()] 116 | param( 117 | [INT]$APGroup = 0 118 | ) 119 | 120 | #Login, Must Call New-RuckusSession First! 121 | LoginToRuckus 122 | 123 | #Grab Active Clients 124 | $Clients = Invoke-RestMethod ($Global:RuckusLoginPage + 'admin/_cmdstat.jsp') -WebSession $RuckusSession -Method POST -Body "" 125 | $Clients.'ajax-response'.response.'apgroupview'.group[$APGroup].'ap' | Select-Object id,mac,devname,description,model 126 | } 127 | 128 | function New-RuckusSession 129 | { 130 | param( 131 | [CmdletBinding()] 132 | [Parameter(Mandatory=$True)] 133 | [STRING]$Uri, 134 | [Parameter(Mandatory=$True)] 135 | [STRING]$Password, 136 | 137 | [STRING]$Username = "admin", 138 | [SWITCH]$IgnoreCertificate 139 | ) 140 | 141 | #Used If There Is No SSL Certificate 142 | if($IgnoreCertificate) { 143 | [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} 144 | } 145 | $Global:RuckusUsername = $Username 146 | $Global:RuckusPassword = $Password 147 | $Global:RuckusLoginPage = $Uri 148 | } 149 | 150 | function isValidMac 151 | { 152 | param( 153 | [Parameter(Mandatory=$True)] 154 | [String]$MacAddress 155 | ) 156 | if(-not [REGEX]::IsMatch($MacAddress,"^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$")) { 157 | Write-Error "$($MacAddress) is not a valid MAC Address, please check it and try again" -ErrorAction Stop 158 | } 159 | } 160 | 161 | function LoginToRuckus 162 | { 163 | if([STRING]::IsNullOrWhiteSpace($Global:RuckusLoginPage)) { 164 | Write-Error "Call New-RuckusSession Before Calling This" -ErrorAction Stop 165 | } 166 | 167 | $Request = Invoke-WebRequest ($Global:RuckusLoginPage+'/admin/login.jsp') -WebSession $RuckusSession -Method POST -Body "username=$($Global:RuckusUsername)&password=$($Global:RuckusPassword)&ok=Log+In" 168 | if(($Request).ParsedHtml.title -eq "Log In") { 169 | Write-Error "Failed to login to $($Global:RuckusLoginPage), check Username/Password" -ErrorAction Stop 170 | } 171 | } -------------------------------------------------------------------------------- /Ruckus/Virtual Smart Zone/Ruckus-SmartZone.ps1: -------------------------------------------------------------------------------- 1 | $Session = New-Object Microsoft.PowerShell.Commands.WebRequestSession 2 | $UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36" 3 | 4 | function New-RuckusSession 5 | { 6 | param( 7 | [Parameter(Mandatory=$true)] 8 | [Uri]$Uri, 9 | [Parameter(Mandatory=$true)] 10 | [System.Management.Automation.PSCredential]$Credential 11 | ) 12 | 13 | $Execution = ((Invoke-WebRequest -Uri $Uri -WebSession $Session).InputFields | Where-Object 'name' -Like 'execution').Value 14 | $Body = $("username="+$($Credential.UserName)+"&password="+$($Credential.GetNetworkCredential().Password+"&execution="+$Execution+"&_eventId=submit&geolocation=")) 15 | $Time = [LONG](New-TimeSpan -Start (Get-Date "01/01/1970") -End (Get-Date)).TotalMilliseconds 16 | $Headers = @{'Content-Type' = "text/plain;charset=UTF-8"} 17 | 18 | Invoke-WebRequest -Method Post -Uri $Uri -Body $Body -UserAgent $UserAgent -WebSession $Session | Out-Null 19 | 20 | #Invoke-WebRequest -Headers $Headers -Method Post -Uri ("https://SNIP/wsg/api/public/v8_0/query/client?_dc="+$Time) -WebSession $Session -Body '{"filters":[{"type":"DOMAIN","value":"SNIP"}],"fullTextSearch":{"type":"AND","value":""},"attributes":["*"],"sortInfo":{"sortColumn":"clientMac","dir":"ASC"},"page":1,"limit":8}' 21 | 22 | 23 | } 24 | 25 | function Get-ActiveClient 26 | { 27 | } 28 | 29 | function Get-GetAPClientConnectedTo 30 | { 31 | param( 32 | [Parameter(Mandatory=$true)] 33 | [String]$Client, 34 | [Parameter(Mandatory=$true)] 35 | [String]$Uri 36 | ) 37 | $Time = [LONG](New-TimeSpan -Start (Get-Date "01/01/1970") -End (Get-Date)).TotalMilliseconds 38 | #DOMAIN = Unique, Find Out Where It Is, Then Use IT? 39 | $Body = "{`"filters`":[{`"type`":`"DOMAIN`",`"value`":`"SNIP`"}],`"fullTextSearch`":{`"type`":`"AND`",`"value`":`""+$Client+"`"},`"attributes`":[`"*`"],`"sortInfo`":{`"sortColumn`":`"clientMac`",`"dir`":`"ASC`"},`"page`":1,`"limit`":8}" 40 | $Headers = @{'Content-Type' = "text/plain;charset=UTF-8"; 'X-Requested-With' = "XMLHttpRequest"} 41 | $Reply = Invoke-WebRequest -UserAgent $UserAgent -Method Post -WebSession $Session -Uri ("https://"+$Uri+":8443/wsg/api/public/v8_0/query/client?_dc="+$Time) -Body $Body -Headers $Headers 42 | $Content = $Reply.Content | ConvertFrom-Json 43 | 44 | $Reply = Invoke-WebRequest -UserAgent $UserAgent -Method Get -WebSession $Session -Uri ("https://"+$Uri+":8443/wsg/api/scg/aps/"+$Content.'list'[0].'apMac'+"/config?_dc="+$Time) 45 | $Content = $Reply.Content | ConvertFrom-Json 46 | $Content.'data'.'description' 47 | } 48 | 49 | New-RuckusSession "https://SNIP/cas/login?service=/wsg/login/cas" 50 | Get-GetAPClientConnectedTo -Uri "SNIP" -Client "F8:1F:32:15:32:26" 51 | -------------------------------------------------------------------------------- /SpiceWorks/README.MD: -------------------------------------------------------------------------------- 1 | # Spiceworks 2 | This is only a script that replicates the authorization of SpiceWorks, you can use the list below to get any information you want from the respective endpoint. It was tested on SpiceWorks Version 7.5.00107 3 | 4 | ### End Points 5 | [Source](https://community.spiceworks.com/topic/144808-spiceworks-api-question?page=1#entry-803046) 6 | * POST /api_v2/:id/run_signed(.:format) 7 | * GET /api/alerts(.:format) 8 | * POST /api/alerts(.:format) 9 | * GET /api/alerts/new(.:format) 10 | * GET /api/alerts/:id/edit(.:format) 11 | * GET /api/alerts/:id(.:format) 12 | * PUT /api/alerts/:id(.:format) 13 | * DELETE/api/alerts/:id(.:format) 14 | * GET /api/groups/multiple(.:format) 15 | * GET /api/groups(.:format) 16 | * POST /api/groups(.:format) 17 | * GET /api/groups/new(.:format) 18 | * GET /api/groups/:id/edit(.:format) 19 | * GET /api/groups/:id(.:format) 20 | * PUT /api/groups/:id(.:format) 21 | * DELETE/api/groups/:id(.:format) 22 | * GET /api/devices(.:format) 23 | * POST /api/devices(.:format) 24 | * GET /api/devices/new(.:format) 25 | * GET /api/devices/:id/edit(.:format) 26 | * GET /api/devices/:id(.:format) 27 | * PUT /api/devices/:id(.:format) 28 | * DELETE/api/devices/:id(.:format) 29 | * GET /api/disks(.:format) 30 | * POST /api/disks(.:format) 31 | * GET /api/disks/new(.:format) 32 | * GET /api/disks/:id/edit(.:format) 33 | * GET /api/disks/:id(.:format) 34 | * PUT /api/disks/:id(.:format) 35 | * DELETE/api/disks/:id(.:format) 36 | * GET /api/data_monitors(.:format) 37 | * POST /api/data_monitors(.:format) 38 | * GET /api/data_monitors/new(.:format) 39 | * GET /api/data_monitors/:id/edit(.:format) 40 | * GET /api/data_monitors/:id(.:format) 41 | * PUT /api/data_monitors/:id(.:format) 42 | * DELETE/api/data_monitors/:id(.:format) 43 | * GET /api/tickets(.:format) 44 | * POST /api/tickets(.:format) 45 | * GET /api/tickets/new(.:format) 46 | * GET /api/tickets/:id/edit(.:format) 47 | * GET /api/tickets/:id(.:format) 48 | * PUT /api/tickets/:id(.:format) 49 | * DELETE/api/tickets/:id(.:format) 50 | * GET /api/ticket_views(.:format) 51 | * POST /api/ticket_views(.:format) 52 | * GET /api/ticket_views/new(.:format) 53 | * GET /api/ticket_views/:id/edit(.:format) 54 | * GET /api/ticket_views/:id(.:format) 55 | * PUT /api/ticket_views/:id(.:format) 56 | * DELETE/api/ticket_views/:id(.:format) 57 | * GET /api/users(.:format) 58 | * POST /api/users(.:format) 59 | * GET /api/users/new(.:format) 60 | * GET /api/users/:id/edit(.:format) 61 | * GET /api/users/:id(.:format) 62 | * PUT /api/users/:id(.:format) 63 | * DELETE/api/users/:id(.:format) 64 | * GET /api/remote_collectors(.:format) 65 | * POST /api/remote_collectors(.:format) 66 | * GET /api/remote_collectors/new(.:format) 67 | * GET /api/remote_collectors/:id/edit(.:format) 68 | * GET /api/remote_collectors/:id(.:format) 69 | * PUT /api/remote_collectors/:id(.:format) 70 | * DELETE/api/remote_collectors/:id(.:format) 71 | * GET /api/reports(.:format) 72 | * POST /api/reports(.:format) 73 | * GET /api/reports/new(.:format) 74 | * GET /api/reports/:id/edit(.:format) 75 | * GET /api/reports/:id(.:format) 76 | * PUT /api/reports/:id(.:format) 77 | * DELETE/api/reports/:id(.:format) 78 | * GET /api/software(.:format) 79 | * POST /api/software(.:format) 80 | * GET /api/software/new(.:format) 81 | * GET /api/software/:id/edit(.:format) 82 | * GET /api/software/:id(.:format) 83 | * PUT /api/software/:id(.:format) 84 | * DELETE/api/software/:id(.:format) 85 | * GET /api/services(.:format) 86 | * POST /api/services(.:format) 87 | * GET /api/services/new(.:format) 88 | * GET /api/services/:id/edit(.:format) 89 | * GET /api/services/:id(.:format) 90 | * PUT /api/services/:id(.:format) 91 | * DELETE/api/services/:id(.:format) 92 | * GET /api/hotfixes(.:format) 93 | * POST /api/hotfixes(.:format) 94 | * GET /api/hotfixes/new(.:format) 95 | * GET /api/hotfixes/:id/edit(.:format) 96 | * GET /api/hotfixes/:id(.:format) 97 | * PUT /api/hotfixes/:id(.:format) 98 | * DELETE/api/hotfixes/:id(.:format) 99 | * GET /api/timeline(.:format) 100 | * POST /api/timeline(.:format) 101 | * GET /api/timeline/new(.:format) 102 | * GET /api/timeline/:id/edit(.:format) 103 | * GET /api/timeline/:id(.:format) 104 | * PUT /api/timeline/:id(.:format) 105 | * DELETE/api/timeline/:id(.:format) 106 | * GET /api/warranties/for_device(.:format) 107 | * GET /api/warranties(.:format) 108 | * POST /api/warranties(.:format) 109 | * GET /api/warranties/new(.:format) 110 | * GET /api/warranties/:id/edit(.:format) 111 | * GET /api/warranties/:id(.:format) 112 | * PUT /api/warranties/:id(.:format) 113 | * DELETE/api/warranties/:id(.:format) 114 | * GET /api/vendors(.:format) 115 | * POST /api/vendors(.:format) 116 | * GET /api/vendors/new(.:format) 117 | * GET /api/vendors/:id/edit(.:format) 118 | * GET /api/vendors/:id(.:format) 119 | * PUT /api/vendors/:id(.:format) 120 | * DELETE/api/vendors/:id(.:format) 121 | * GET /api/purchases(.:format) 122 | * POST /api/purchases(.:format) 123 | * GET /api/purchases/new(.:format) 124 | * GET /api/purchases/:id/edit(.:format) 125 | * GET /api/purchases/:id(.:format) 126 | * PUT /api/purchases/:id(.:format) 127 | * DELETE/api/purchases/:id(.:format) 128 | * GET /api/virtual_machines/for_user(.:format) 129 | * GET /api/virtual_machines(.:format) 130 | * POST /api/virtual_machines(.:format) 131 | * GET /api/virtual_machines/new(.:format) 132 | * GET /api/virtual_machines/:id/edit(.:format) 133 | * GET /api/virtual_machines/:id(.:format) 134 | * PUT /api/virtual_machines/:id(.:format) 135 | * DELETE/api/virtual_machines/:id(.:format) 136 | * GET /api/user_role(.:format) 137 | -------------------------------------------------------------------------------- /SpiceWorks/SpiceWorks.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param( 3 | [string] $url = "", 4 | [string] $username = "", 5 | [string] $password = '' 6 | ) 7 | 8 | $userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0" 9 | $headers = @{"Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; "Accept-Encoding"="gzip, deflate"; "Accept-Language"="en-US,en;q=0.5";} 10 | $LogonPage = Invoke-WebRequest ($url) -SpiceSessionVariable SpiceSession -UserAgent $userAgent -Headers $headers 11 | $CookieContainer = New-Object System.Net.CookieContainer 12 | $SpiceSession.Headers.Add("Cookie", $CookieContainer.GetCookieHeader($url)) 13 | 14 | $formFieldsText = "authenticity_token="+[System.Net.WebUtility]::UrlEncode($LogonPage.Forms[0].Fields["authenticity_token"])+"&_pickaxe=%E2%B8%95&pro_user%5Bemail%5D="+[System.Net.WebUtility]::UrlEncode($username)+"&pro_user%5Bpassword%5D="+[System.Net.WebUtility]::UrlEncode($password)+"&pro_user%5Bremember_me%5D=0" 15 | 16 | $Reply = Invoke-WebRequest ($url) -WebSpiceSession $SpiceSession -Method POST -Body $formFieldsText -UserAgent $userAgent -Headers $headers -ErrorAction SilentlyContinue | Out-Null -------------------------------------------------------------------------------- /WorkHarderNotSmarter.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /Yealink/Login-ToPhone.ps1: -------------------------------------------------------------------------------- 1 | #$ErrorActionPreference="SilentlyContinue" 2 | 3 | $Scopes = @( 4 | 5 | ) 6 | $Phones = New-Object System.Collections.ArrayList 7 | 8 | function Login-ToPhone 9 | { 10 | param( 11 | $Phone 12 | ) 13 | 14 | $PhoneSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession 15 | 16 | #$Phone.IPAddress = "10.57.178.30" 17 | Write-Host $Phone.IPAddress 18 | 19 | $Body = Invoke-WebRequest -Uri "http://$($Phone.IPAddress)/servlet?p=login&q=login" -Body "username=admin&pwd=***&jumpto=account-register-lync" -WebSession $PhoneSession -Method Post -Headers @{"Expect"="200-ok"} #-ErrorAction Suspend 20 | $Body -Match "(\d{11}|\d{10}|\d{9})" | Out-Null 21 | $LoginToken = $Matches[0] 22 | $Body.RawContent -Match "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" | Out-Null #Don't You Just LOVE Regex? 23 | $User = $Matches[0] 24 | 25 | Write-Host "Success! (Didn't See That Coming...) Token: $LoginToken User:$User" 26 | $User = $User.Substring(0, $User.LastIndexOf('.')) 27 | $User = $User+".nz" #Just making sure it ENDS in .nz not some random letters 28 | $User = [URI]::EscapeDataString($User) 29 | 30 | Invoke-WebRequest -Uri "http://$($Phone.IPAddress)/servlet?p=account-register-lync&q=write&acc=0" -Body "var_accountID=0&server1=$($User)&AccountRegisterName=$($User)&AccountPassword=********&token=$($LoginToken)" -WebSession $PhoneSession -Method Post -Headers @{"Expect"="200-ok"} | Out-Null 31 | Write-Host "Sweet Victory!" 32 | } 33 | 34 | foreach($Scope in $Scopes) 35 | { 36 | Write-Host "Checking $Scope" 37 | $Clients = $(Get-DhcpServerv4Lease $Scope | Select-Object IPAddress,ClientId,HostName) 38 | foreach($Client in $Clients) 39 | { 40 | if($Client.HostName -ne $null -and $Client.ClientId -ne $null) 41 | { 42 | if($Client.HostName.StartsWith("YEALINK") -or $Client.ClientId.StartsWith("00-15-65-92")) 43 | { 44 | Test-Connection $Client.IPAddress -Count 2 -Quiet | Out-Null 45 | if(-not $?) 46 | { 47 | Write-Warning "Phone $($Client.HostName) is offline or otherwise unreachable..." 48 | continue 49 | } 50 | 51 | Write-Host "Logging In: $($Client.HostName)" 52 | Login-ToPhone $Client 53 | } 54 | } 55 | } 56 | Write-Host "----------" 57 | } -------------------------------------------------------------------------------- /Yealink/README.MD: -------------------------------------------------------------------------------- 1 | # Yealink Phone 2 | 3 | This script has a few handy functions in it to handle dealing with [Yealink T22 phones](https://www.yealink.com/products_75.html) (Yep, they're EOL...). There isn't much to cover in this but I will update this README once all the functions have been updated and verified they work. 4 | -------------------------------------------------------------------------------- /Yealink/Yealink.ps1: -------------------------------------------------------------------------------- 1 | [String]$PhoneIP = "" 2 | [String]$User= "" 3 | [String]$Pass= "" 4 | $PhoneSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession 5 | 6 | #This Is Important, It's The Auth Token For The Session!!! 7 | [String]$Token = "" 8 | 9 | #Setup Connection To Phone 10 | function New-YealinkSession 11 | { 12 | param( 13 | [Parameter(Mandatory=$true)] 14 | [String]$PhoneIP, 15 | [Parameter(Mandatory=$true)] 16 | [String]$Password, 17 | [Parameter()] 18 | [String]$Username = "admin" 19 | ) 20 | 21 | testConnection 22 | 23 | #Post Login With Information 24 | $PostBody = "username=$($Username)&pwd=$($Password)&jumpto=status&acc=" 25 | (Invoke-WebRequest -Uri "http://$($PhoneIP)/servlet?p=login&q=login" -Body $PostBody -Method Post -WebSession $PhoneSession -Headers @{"Expect"="200-ok"}) -match "(\d{9})" | Out-Null 26 | $Script:Token = $Matches[0] #This Token shows we're auth'd, it needs to be included in most (if not all?) post requests. 27 | } 28 | 29 | function Restart-Phone 30 | { 31 | param( 32 | [Parameter(Mandatory=$true)] 33 | [String]$PhoneIP 34 | ) 35 | 36 | testConnection 37 | 38 | Invoke-WebRequest -Uri "http://$($PhoneIP)/servlet?p=settings-upgrade&q=reboot" -Body "token=$($Script:Token)" -Method Post -WebSession $PhoneSession | Out-Null 39 | Write-Warning "Phone reboot request sent, You will NEED to call New-YeaLinkSession after it reboots." 40 | #Has To Be A Fresh(Prince of Bel-Air) Session and Token since the session state is invalidated after a reboot. (That's why we need to call) 41 | } 42 | 43 | function Set-PhoneAccount 44 | { 45 | param( 46 | [Parameter(Mandatory=$True)] 47 | [String]$PhoneIP, 48 | [Parameter(Mandatory=$True)] 49 | [String]$LoginAddress, 50 | #Just Default To Using Login Address As Well... 51 | [String]$RegisterName = $LoginAddress, 52 | [Parameter(Mandatory=$True)] 53 | [String]$Password 54 | ) 55 | 56 | testConnection 57 | #Account ID=You can have multiple accounts on some VOIP phones, Server1 and AccountRegistername are the same in my expernice. 58 | $PostBody = ("var_accountID=0&server1=$([URI]::EscapeDataString($LoginAddress))&AccountRegisterName=$([URI]::EscapeDataString($RegisterName))&AccountPassword=$($Password)&token=$($Script:Token)") 59 | Invoke-WebRequest -Uri "http://$($PhoneIP)/servlet?p=account-register-lync&q=write&acc=0" -Body $PostBody -Method Post -WebSession $PhoneSession -Headers @{"Host"=$PhoneIP}| Out-Null 60 | } 61 | 62 | function testConnection 63 | { 64 | Write-Progress "Testing Connection To Phone" 65 | Test-Connection $PhoneIP -Count 2 -Quiet | Out-Null 66 | if( -not $?) 67 | { 68 | Write-Error "Phone is offline or otherwise unreachable..." -ErrorAction Stop 69 | } 70 | } 71 | 72 | function Set-PhoneNetworkDHCP 73 | { 74 | param( 75 | [Parameter(Mandatory=$true)] 76 | [String]$PhoneIP, 77 | [Switch]$NoReboot = $false 78 | ) 79 | 80 | testConnection 81 | 82 | $PostBody = "NetworkIPAddressMode=0&NetworkWanType=0&NetworkWanStaticDNSEnable=0&token=$($Token)" 83 | Invoke-WebRequest -Uri "http://$($PhoneIP)/servlet?p=network&q=write&ipv4type=0&ipv6type=0&reboot=$(-not $NoReboot.IsPresent)" -Body $PostBody -Method Post -WebSession $PhoneSession | Out-Null 84 | } 85 | 86 | function Set-PhoneNetworkStatic 87 | { 88 | param( 89 | [Parameter(Mandatory=$true)] 90 | [String]$PhoneIP 91 | ) 92 | } --------------------------------------------------------------------------------