Posts

Showing posts from November, 2018

Ways to execute PowerShell (PS1) scripts in remote computers

Below are ways to execute PowerShell (PS1) scripts in remote computers: Example 1: invoke-command -computerName MySrv1 -filepath .\test.ps1 Example 2: Get the version of the PowerShell host running on a remote computer: invoke-command -computername server64 -scriptblock {(get-host).version} Example 3: Get the version of the PowerShell host running on a list of remote computers (computers.txt): PS C:\> $version = invoke-command -computername (get-content computers.txt) -scriptblock {(get-host).version} PS C:\> $version Example 4: Run the Sample.ps1 script on all of the computers listed in the Servers.txt file. Using the -FilePath parameter to specify the script file has the effect that the content of the script is automatically copied into a script block and then passed to and run on each of the remote computers: PS C:\> invoke-command -comp (get-content servers.txt) -filepath c:\scripts\sample.ps1 -argumentlist Process, Service Alternatives method: Inv

TLS versions 1.0, 1.1 and 1.2 in Windows servers

When there is communication issue from client to server due to TLS versions, below values in Registry needs to be checked: Reg values to check for: DisabledByDefault REG_DWORD 1 or 0 Enabled REG_DWORD 1 or 0 Reg paths: TLS 1.0 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server TLS 1.1 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server TLS 1.2 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server Clients may need this update for compatible TLS versions: https://support.microsoft.com/en-sg/help/3080079/up

PowerCLI commands to manage VMs

PowerCLI - Get-Member - Get all properties of an object To Open VM Console: Get-VM VMName | Open-VMConsoleWindow To get VM Properterties : Get-VM | Get-Member -MemberType property | Format-Table -Property Name To set browser for VM Console: Set-PowerCLIConfiguration –VMConsoleWindowBrowser “C:\Program Files ( x86 ) \Mozilla Firefox\ firefox.exe ” #To set the browser Set-PowerCLIConfiguration –VMConsoleWindowBrowser “ $ null ” #To clear above setting Get-HardDisk -VM Output like this: CapacityGB Persistence Filename Appendix - Command outputs: Output: Name ---- CDDrives CustomFields DatastoreIdList Description DrsAutomationLevel ExtensionData FloppyDrives Folder FolderId Guest HAIsolationResponse HardDisks HARestartPriority Host HostId Id MemoryMB Name NetworkAdapters Notes NumCpu PersistentId PowerState ProvisionedSpaceGB ResourcePool ResourcePoolId Uid UsbDevices UsedSpaceGB VApp Version VMHost VMHostId VMResourceConfiguration VMSwapfilePolicy I

[Windows][Commands] Get DNS servers of a domain

Ways to get DNS servers of a domain: Method 1: nslookup > set type=NS > Outputs: Non-authoritative answer:   nameserver = DNSserverNamel   nameserver = DNSserverName2 DNSserverNamel     internet address = DNSserverIPl DNSserverName2    internet address = DNSserverIP2 Method 2: nltest /dnsgetdc: Output: List of DCs in pseudo-random order taking into account SRV priorities and weights: Non-Site specific:    DNSserverNamel  DNSserverIPl    DNSserverName2  DNSserverIP2 The command completed successfully.