Skip to content

Instantly share code, notes, and snippets.

View KelvinTegelaar's full-sized avatar

KelvinTegelaar

View GitHub Profile
#Checking if ToastReboot:// protocol handler is present
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -erroraction silentlycontinue | out-null
$ProtocolHandler = get-item 'HKCR:\ToastReboot' -erroraction 'silentlycontinue'
if (!$ProtocolHandler) {
#create handler for reboot
New-item 'HKCR:\ToastReboot' -force
set-itemproperty 'HKCR:\ToastReboot' -name '(DEFAULT)' -value 'url:ToastReboot' -force
set-itemproperty 'HKCR:\ToastReboot' -name 'URL Protocol' -value '' -force
New-item 'HKCR:\ToastReboot\Shell\Open\command' -force
set-itemproperty 'HKCR:\ToastReboot\Shell\Open\command' -name '(DEFAULT)' -value 'C:\Windows\System32\shutdown.exe -r -t 60' -force
#What is an API, What is REST.
#Some PowerShell examples, using Netsapiens. The platform behind OITVoip.
#Set your credentials
$baseurl = "https://manage.oitvoip.com/ns-api/"
$ClientID = '99999demo.client'
$Secret = 'SuperSecret'
$Username = 'Username'
$Password = 'Password'
#Run first time
$Exchangetoken = New-PartnerAccessToken -ApplicationId 'a0c73c16-a7e3-4564-9a95-2bdf47383716' -Scopes 'https://outlook.office365.com/.default' -Tenant $TenantID -UseDeviceAuthentication
write-host "Exchange Token: $($ExchangeToken.RefreshToken)"
#Run each following time
$ExchangeRefreshToken = 'ExchangeRefreshToken'
$UPN = "YourUPNHere@upn.com
$token = New-PartnerAccessToken -ApplicationId 'a0c73c16-a7e3-4564-9a95-2bdf47383716'-RefreshToken $ExchangeRefreshToken -Scopes 'https://outlook.office365.com/.default'
$tokenValue = "Bearer $($token.AccessToken)"
######### Secrets #########
$ApplicationId = 'AppID'
$ApplicationSecret = 'Appsecret' | ConvertTo-SecureString -Force -AsPlainText
$TenantID = 'TenantID'
$RefreshToken = 'RefreshToken'
$ExchangeRefreshToken = 'ExchangeRefreshtoken'
$UPN = 'Upnusedtogeneratetokens'
$Skiplist = "One.onmicrosoft.com", "Two.onmicrosoft.com"
######### Secrets #########
$credential = New-Object System.Management.Automation.PSCredential($ApplicationId, $ApplicationSecret)
######### Secrets #########
$ApplicationId = 'AppID'
$ApplicationSecret = 'Appsecret' | ConvertTo-SecureString -Force -AsPlainText
$TenantID = 'TenantID'
$RefreshToken = 'RefreshToken'
$ExchangeRefreshToken = 'ExchangeRefreshtoken'
$UPN = 'Upnusedtogeneratetokens'
$Skiplist = "One.onmicrosoft.com", "Two.onmicrosoft.com"
######### Secrets #########
$credential = New-Object System.Management.Automation.PSCredential($ApplicationId, $ApplicationSecret)
######### Secrets #########
$ApplicationId = 'AppID'
$ApplicationSecret = 'AppSecret' | ConvertTo-SecureString -Force -AsPlainText
$RefreshToken = 'RefreshToken'
$APIKEy = "LangeITGlueAPIKeyHier"
$APIEndpoint = "https://api.eu.itglue.com"
######### Secrets #########
$CustomerTenant = "Client.onmicrosoft.com"
$ITGlueORGID = "123456"
########################## Script Settings ############################
$IPList = @(
"1.1.1.1"
"2.2.2.2"
"3.3.3.3"
"4.4.4.4"
)
$LocationInfo = foreach ($ip in $IPList) {
$Location = (Invoke-restmethod -method get -uri "https://ip2c.org/$($ip)") -split ';' | Select-Object -Last 1
###############
$ITGkey = "ITGAPIKey"
$ITGbaseURI = "https://api.eu.itglue.com"
$UnifiBaseUri = "https://YourController.com:8443/api"
$UnifiUser = "APIUSER"
$UnifiPassword = "APIPAssword"
$FlexAssetName = "Unifi Controller Autodoc Vcampai"
$Description = "A network one-page document that displays the unifi status."
##############
###############
$UnifiBaseUri = "https://Controller.com:8443/api"
$UnifiUser = "APIUSER"
$UnifiPassword = "APIPASSWORD"
##############
$UniFiCredentials = @{
username = $UnifiUser
password = $UnifiPassword
remember = $true