Tag: remote

Azure

Start Azure VM and Open Bastion

The following snippet will check if a VM is turned on, and if not start it, then launch the Bastion connection window in Edge. $VM = Get-AzVM -Name 'LN-TCTester-01' -Status if($VM.PowerState -eq 'VM deallocated'){ $VM | Start-AzVM } Start-Process -Path msedge -ArgumentList "https://portal.azure.com/#/resource$($VM.Id)/bastionHost"
RemotingSecurity

Run PSExec From PowerShell

PowerShell remoting help in a lot of areas, but there are times when you need to use PSExec. For those instances, I’ve created a function that you can use to run a command on a remote machine using PSExec. Function ExecutePsExec($computer, $command){ $ping = Test-Connection $computer -Count 1 -Quiet if($ping){ $StdOutput = (Join-path $env:temp "$($computer).txt") Start-Process -FilePath $psexec -ArgumentList "-s...
RegistrySystems

Query Remote Registry for Key Value

# Open the specified Registry Hive on a remote machine specified. LocalMachine = HKLM / CurrentUser = HKCU $computer = 'localhost' $w32reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$computer) # Open the specific registry key (exclude hive from path) $keypath = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI' $SubKey = $w32reg.OpenSubKey($keypath) # Return data for a specific value $SubKey.GetValue('LastLoggedOnUser') # List all values $SubKey.GetValueNames() # Return data for all values to...