Skip to content

Instantly share code, notes, and snippets.

View mikebranstein's full-sized avatar

Mike Branstein mikebranstein

View GitHub Profile
@mikebranstein
mikebranstein / screen-resolution.ps1
Created September 1, 2016 21:12
Set the screen resolution of a Windows 10 iot core device with powershell
SetDisplayResolution 1024 768
@mikebranstein
mikebranstein / remotely-disable-windows-update.ps1
Created September 1, 2016 20:32
Remotely execute a script to disable Windows Update with PowerShell
Write-Host "Disabling Windows Update on $deviceName..."
Invoke-Command -Session $session -FilePath .\Disable-WindowsUpdate.ps1
@mikebranstein
mikebranstein / disable-windows-update.ps1
Created September 1, 2016 20:26
Disables Windows Update with PowerShell
# set the Windows Update service to "disabled"
sc.exe config wuauserv start=disabled
# display the status of the service
sc.exe query wuauserv
# stop the service, in case it is running
sc.exe stop wuauserv
# display the status again, because we're paranoid
@mikebranstein
mikebranstein / Install-WiFiDriver.ps1
Created August 24, 2016 18:51
install wifi driver with powershell
cd C:\EFIESP\temp
devcon install netrtwlanu.inf "USB\VID_7392&PID7811"
@mikebranstein
mikebranstein / run-remote-command-install-wifi.ps1
Created August 24, 2016 18:50
Run remote powershell script to install wifi drivers
Invoke-Command -Session $session -FilePath .\Install-WifiDriver.ps1
@mikebranstein
mikebranstein / copy-wifi-drivers.ps1
Created August 24, 2016 18:44
Copy WiFi drivers to a remote device
Copy-Item -ToSession $session -Path ".\Driver\" -Destination "C:\EFIESP\temp\" -Recurse -Force -ErrorAction SilentlyContinue
@mikebranstein
mikebranstein / rename-device-full.ps1
Created August 24, 2016 17:52
Full code for renaming a device remotely with PowerShell
# Trust the remote pi and connect to it
Write-Host "Configuring WinRM TrustedHosts..."
$trustedHosts = Get-Item WSMan:\localhost\Client\TrustedHosts
if ($trustedHosts.Value -eq "") {
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $ipAddress -Force
}
elseif (-not $trustedHosts.Value.Contains($ipAddress)) {
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$($trustedHosts.Value),$($ipAddress)" -Force
}
@mikebranstein
mikebranstein / remote-rename-device.ps1
Created August 24, 2016 17:51
Remotely rename a device with PowerShell
Invoke-Command -Session $session -FilePath .\Rename-Device.ps1 -ArgumentList $deviceName
@mikebranstein
mikebranstein / Rename-Device.ps1
Last active August 24, 2016 17:50
Remotely rename a device with PowerShell
Param (
[string][Parameter(Mandatory = $true)] $deviceName
)
setcomputername $deviceName
@mikebranstein
mikebranstein / establish-remote-powershell-session.ps1
Created August 24, 2016 17:41
Establish a remote PowerShell session
$username = "administrator"
$password = "your-super-secret-password"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $securePassword
$pstimeout = New-PSSessionoption -OperationTimeout (1000*60*5)
$session = New-PSSession -computer $ipAddress -Credential $cred -ErrorAction Stop -SessionOption $pstimeout