filmov
tv
PowerShell - Sendkeys remote
Показать описание
In this video I demonstrate how and if you can use sendkeys remotely.
I got questioned a couple of times, if I could create a video on sending keys remotely.
The video content should create some understanding about the limitations of sendkeys as well.
*powershell sendkeys
*powershell sendkeys remote
*sendkeys remote
*remote sendkeys
*remote sendkey
*automation
*learn automation
*sendkeys
*sendkeys remote
*windows
*windows powershell
*automatic deployment
*automatic installations
*configuration as code
Code :
function clicker{
start-sleep -Seconds 10
try {
Start-Sleep -Milliseconds 5000
[Microsoft.VisualBasic.Interaction]::AppActivate("Document - Wordpad")
#[System.Windows.Forms.SendKeys]::SendWait(" ")
[System.Windows.Forms.SendKeys]::SendWait("h")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("e")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("o")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%{f}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{DOWN 3}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("h")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("e")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("o")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%{F4}")
}
catch {#ignore
}
}
#add-type -AssemblyName System.Windows.Forms
#add-type -AssemblyName microsoft.VisualBasic
[void] [System.Reflection.Assembly]::LoadWithPartialName("microsoft.VisualBasic")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#start-process "notepad"
start-sleep -Seconds 5
clicker
code to set autologon and copy the script over.
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value "home\$using:NewVmName"
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value MyPassword
}
New-SmbMapping -RemotePath "\\$IP\c$" -UserName $AdminCreds.UserName -Password $rootcred_salt
I got questioned a couple of times, if I could create a video on sending keys remotely.
The video content should create some understanding about the limitations of sendkeys as well.
*powershell sendkeys
*powershell sendkeys remote
*sendkeys remote
*remote sendkeys
*remote sendkey
*automation
*learn automation
*sendkeys
*sendkeys remote
*windows
*windows powershell
*automatic deployment
*automatic installations
*configuration as code
Code :
function clicker{
start-sleep -Seconds 10
try {
Start-Sleep -Milliseconds 5000
[Microsoft.VisualBasic.Interaction]::AppActivate("Document - Wordpad")
#[System.Windows.Forms.SendKeys]::SendWait(" ")
[System.Windows.Forms.SendKeys]::SendWait("h")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("e")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("o")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%{f}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{DOWN 3}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("h")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("e")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("l")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("o")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%{F4}")
}
catch {#ignore
}
}
#add-type -AssemblyName System.Windows.Forms
#add-type -AssemblyName microsoft.VisualBasic
[void] [System.Reflection.Assembly]::LoadWithPartialName("microsoft.VisualBasic")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#start-process "notepad"
start-sleep -Seconds 5
clicker
code to set autologon and copy the script over.
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value "home\$using:NewVmName"
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value MyPassword
}
New-SmbMapping -RemotePath "\\$IP\c$" -UserName $AdminCreds.UserName -Password $rootcred_salt
Комментарии