Skip to content

Instantly share code, notes, and snippets.

View OSDTips's full-sized avatar

Lars Krogh Paulsen OSDTips

View GitHub Profile
# Change all public profile NICs to become Work Network NICs
$nlm = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]”{DCB00C01-570F-4A9B-8D69-199FDBA5723B}”))
$connections = $nlm.getnetworkconnections()
$connections |foreach {
if ($_.getnetwork().getcategory() -eq 0) {
$_.getnetwork().setcategory(1)
}
}
# Set-ExecutionPolicy without confirmation
$shell = New-Object -ComObject Wscript.Shell
Set-ExecutionPolicy Unrestricted | Echo $shell.sendkeys("Y`r`n")
# Configure WinRM client
winrm qc
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/service/auth '@{Kerberos="false"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/client '@{TrustedHosts="*"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}'
start-service WinRM
set-service WinRM -StartupType Automatic
@OSDTips
OSDTips / Set-PowerPlan.ps1
Last active February 9, 2023 17:12
Set-PowerPlan.ps1
$Powerplans = Get-WmiObject -Query "SELECT ElementName,InstanceID,ISActive FROM win32_powerplan" -Namespace root\cimv2\power
$Target = "High performance"
foreach ($Powerplan in $Powerplans) {
if ($Powerplan.ElementName -eq $Target) {
$Powerplan.ElementName
$Powerplan.InstanceID
$Powerplan.ISActive
$Changer = $Powerplan
break
@OSDTips
OSDTips / Disable-IEESC.ps1
Last active November 23, 2015 22:24
Disable-IEESC.ps1
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
if (Test-Path $AdminKey) {Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0}
if (Test-Path $UserKey) {Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0}
@OSDTips
OSDTips / Set-WindowsEventLogSize.ps1
Last active November 22, 2015 22:48
Set-WindowsEventLogSize.ps1
wevtutil sl Application /ms:55000000 /rt:false /ab:false
wevtutil sl Security /ms:135000000 /rt:false /ab:false
wevtutil sl System /ms:55000000 /rt:false /ab:false
@OSDTips
OSDTips / Enable-RemoteDesktop.ps1
Last active November 23, 2015 22:01
Enable-RemoteDesktop.ps1
$obj = Get-WmiObject -Class "Win32_TerminalServiceSetting" -Namespace root\cimv2\terminalservices
if ($obj -eq $null) {return}
$obj.SetAllowTsConnections(1,1) | out-null
@OSDTips
OSDTips / Set-TimeZone.ps1
Last active November 23, 2015 22:21
Set-TimeZone.ps1
$timeZone = 'Romance Standard Time'
$proc = New-Object System.Diagnostics.Process
$proc.StartInfo.WindowStyle = "Hidden"
$proc.StartInfo.FileName = "tzutil.exe"
$proc.StartInfo.Arguments = "/s `"$timeZone`""
@OSDTips
OSDTips / gist:07cb50e8e95a2be71a57
Created May 11, 2015 13:16
Enable-ZoneChecking.ps1
setx.exe SEE_MASK_NOZONECHECKS 0 /M
@OSDTips
OSDTips / Disable-ZoneChecking.ps1
Last active November 23, 2015 22:23
Disable-ZoneChecking.ps1
setx.exe SEE_MASK_NOZONECHECKS 1 /M