This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-NtSecurityDescriptor { | |
param | |
( | |
[string]$SecurityDescriptor | |
) | |
$ntsecdesc = New-Object Byte[] ($SecurityDescriptor.Length) | |
for ($i = 0; $i -lt $SecurityDescriptor.Length ; $i += 2) { | |
$ntsecdesc.Set(($i/2),([Byte]::Parse($SecurityDescriptor.Substring($i, 2), [System.Globalization.NumberStyles]::HexNumber))) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-SidfromHex { | |
param | |
( | |
[string]$Sid | |
) | |
$ByteSid = New-Object Byte[] 150 | |
for ($i = 0; $i -lt $Sid.Length ; $i += 2) { | |
$ByteSid.Set(($i/2),([Byte]::Parse($Sid.Substring($i, 2), [System.Globalization.NumberStyles]::HexNumber))) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$name = 'Dammaschke' # Change | |
$NetworkCategory = 1 # 0 = Public, 1 = Private (2 = Domain, but not setable) | |
$profile = Get-CimInstance -Namespace root/StandardCimv2 -ClassName MSFT_NetConnectionProfile|Where-Object Name -EQ $name | |
$profile.NetworkCategory = $NetworkCategory | |
Set-CimInstance $profile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MD5 for String | |
$hash = [System.Security.Cryptography.MD5]::Create() | |
$byte = [System.Text.Encoding]::UTF8.GetBytes('Test') | |
$md5 = $hash.ComputeHash($byte) | |
([Bitconverter]::ToString($md5)).replace('-','') | |
# MD5 for File | |
$hash = [System.Security.Cryptography.MD5]::Create() | |
$file = [System.IO.File]::ReadAllBytes('E:\Onedrive\Dokumente\Skripte\Powershell Skripte\test.zip') | |
$md5 = $hash.ComputeHash($file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmdkey /generic:{HYPER-V SERVER}\{VMNAME} /user:{USERNAME} /pass:{PASSWORD} | |
C:\WINDOWS\system32\VmConnect.exe "{HYPER-V SERVERNAME}" "{VMNAME}" [/credential LegacyGeneric:target={CREDENTIALNAME} | /user {USERNAME} /password {PASSWORD}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$message = "The size of your desktop folder exceeds 500MB.`r`nThis can cause delays at logon and logoff.`r`n`r`nGreetings from your IT-Department" | |
if ([Math]::Truncate((Get-ChildItem "$env:USERPROFILE\Desktop" -Recurse|Measure-Object -property Length -sum).Sum / 1MB) -gt 500){[System.Windows.Forms.MessageBox]::Show($message)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$OFS =’; ’ | |
$Job = {Get-VM|Stop-VM} | |
Start-Job $Job | |
While((Get-VM|? State -NE 'Off').Count -gt 0) {Write-Host 'VMs' ([string](Get-VM|? State -ne 'Off').Name) 'shutting down...';Start-Sleep 1} | |
Stop-Computer -Force |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ips = @() | |
foreach ($i in 1..254) | |
{ | |
$ips += "192.168.0.$i" | |
} | |
New-NetFirewallRule -Protocol TCP –LocalPort 3389 -Profile Public -DisplayName 'RDP VPN S2S' -Direction Inbound -Action Allow -RemoteAddress $ips |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$nics = Get-CimInstance Win32_NetworkAdapter -Filter 'netenabled = true' | |
$powerenabled = Get-CimInstance -Namespace root\wmi -ClassName MSPower_DeviceWakeEnable | |
$nics|% {if ($powerenabled.InstanceName -match [regex]::Escape($_.PNPDeviceID)) {$powernics = $_.PNPDeviceID}} | |
$Items = $powerenabled|Where-Object {$_.InstanceName -like "$powernics*"} | |
$Items.Enable = $true | |
Set-CimInstance -InputObject $Items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Applies the pending configuration | |
Invoke-CimMethod -Namespace root\Microsoft\Windows\DesiredStateConfiguration -ClassName MSFT_DSCLocalConfigurationManager -MethodName ApplyConfiguration | |
#Starts a consistency check for the last applied config | |
Invoke-CimMethod -Namespace root\Microsoft\Windows\DesiredStateConfiguration -ClassName MSFT_DSCLocalConfigurationManager -MethodName PerformRequiredConfigurationChecks -Arguments @{Flags = [uint32]1} |