Found 989 Articles for Software & Coding

How to test remote computer connectivity using PowerShell?

Chirag Nagrekar
Updated on 28-Jul-2020 09:23:26

2K+ Views

To test the remote connectivity using PowerShell Test-Connection command is used. PowerShell also supports the Ping command and both the commands are almost produce the same output but Test- Connection cmdlet supports advanced parameters. See how both commands output look.Ping Command −PS C:\Temp> ping Test1-Win2k16 Pinging Test1-Win2k16 [192.168.0.108] with 32 bytes of data: Reply from 192.168.0.108: bytes=32 time Test-Connection Test1-win2k16 Source    Destination    IPV4Address    IPV6Address ------    -----------    -----------    ----------- ADDC    Test1-win2k16    192.168.0.108 ADDC    Test1-win2k16    192.168.0.108 ADDC    Test1-win2k16    192.168.0.108 ADDC    Test1-win2k16    192.168.0.108You can reduce the number of checks using ... Read More

How to enable / Disable Enhanced Protection Mode in Internet Explorer using PowerShell?

Chirag Nagrekar
Updated on 28-Jul-2020 09:19:57

760 Views

Internet Explorer (IE) supports the enhanced protection mode for more security of the browser and the same can be enabled/disabled using PowerShell. Let see when we can find this setting in IE.Internet Explorer → Internet Options → Advanced → Enable Enhanced Protection ModeWe can modify this setting using PowerShell and for that registry settings need to be done. Registry value can be found under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main and the key name is Isolation for enhanced protection mode.PMIL – To disable IE enhanced protection ModePMEM – To Enable IE enhanced protection modeTo make the changes using the script.Enable IE EP modeIf there ... Read More

How to test WinRM connectivity using PowerShell?

Chirag Nagrekar
Updated on 25-Jul-2020 11:26:53

13K+ Views

In system admin role or as a PowerShell engineer you need to connect to many computers remotely. So as the first step, we need to test the remote connectivity by applying ping command or Test-Connection but many organizations have a stringent policy, and some of the servers ICMP packets are blocked. In such a case you can check connectivity with WINRM.If the WINRM is not allowed, you can ask your windows administrator to enable a firewall exception for WINRM. WINRM is the thing that PowerShell uses it for remoting purposes. So before connecting to remote server it is necessary to ... Read More

How does PowerShell Remoting work?

Chirag Nagrekar
Updated on 25-Jul-2020 11:23:32

284 Views

There are several ways to connect to remote computer cmdlets. These computers can be in the same domain, different domains, or for the workgroups using PowerShell. Here, we will mainly focus on the inbuilt parameter, Invoke-Command, and to execute PSSession command remotely.Inbuilt -ComputerName parameter.Many cmdlets in PowerShell supports the -ComputerName parameter, which describes the remote computer names. For example, Get-Service, Get-Process, and Get-WMIObject, etc.. cmdlets.ExampleIf the remote server is in the same domain then you just need to simply add -ComputerName credentials.Get-Service Spooler -ComputerName Test1-Win2k12OutputPS C:\Users\Administrator> Get-Service Spooler -ComputerName Test1-Win2k12 Status            Name         ... Read More

How to use –Timeout parameter in Restart-Computer cmdlet in PowerShell?

Chirag Nagrekar
Updated on 24-Jul-2020 10:36:28

1K+ Views

As the name describes, with –Timeout parameter, you can restrict time for validations (PowerShell, WinRM, and WMI connectivity check after reboot) for –Wait and –For parameters and if the checks don’t complete during that time then it returns an error. This timeout value is in seconds. You can specify this parameter with either –Wait or –For parameter but with –For parameter you need to include –Wait parameter as well.When -Timeout is specified with –Wait parameter, the overall checks (3 validations: PowerShell, WMI, and WINRM connectivity) then overall check time is restricted in seconds and when it is used with –For ... Read More

How to use -For parameter in Restart-Computer cmdlet in PowerShell?

Chirag Nagrekar
Updated on 24-Jul-2020 10:35:30

240 Views

In the –Wait parameter 3 main checks are validated − PowerShell, WMI, and WINRM connectivity. So whenever you specify the –Wait parameter, you have to wait until all three checks pass, however, if any of the checks fail then script freezes and can not further execute. If you know which specific check you want to perform then you can specify that value with the –For parameter as shown below.Here, for the example, we will run a single WMI check for the remote server.Restart-Computer Test1-Win2k12 -Wait -For Wmi -Force-For parameter must be used with –Wait parameter. Here, again if something goes ... Read More

How to use –Wait parameter in Restart-Computer cmdlet in PowerShell?

Chirag Nagrekar
Updated on 24-Jul-2020 10:33:36

2K+ Views

When we use Restart-Computer command with the remote computer names, PowerShell restarts the mentioned remote computers without any checks or validations if the server has come up or not. This requirement is fulfilled with the - Wait parameter. Whenever the - Wait parameter specified, PowerShell performs the below 3 checks on the remote computer when the computer is restarting.This can be noticed in the Progress bar of the PowerShell console.PowerShell − If the computer can run the Powershell command on the remote machine.WMI − Performs the WMI query on the remote computer using the Win32_ComputerSystem command.WINRM − Checks the remote ... Read More

How to restart a remote system using PowerShell?

Chirag Nagrekar
Updated on 24-Jul-2020 10:30:17

2K+ Views

To restart the remote computer, you need to use the Restart-Computer command provided by the computer name. For example, Restart-Computer -ComputerName Test1-Win2k12The above command will restart computer Test1-Win2k12 automatically and if you have multiple remote computers to restart then you can provide multiple computers separated with comma (, ).For example, Restart-Computer -ComputerName Test1-Win2k12, Test2-Win2k12Restart signal will be sent to both the computers at a time in the above example.You can also use the Pipeline to restart remote computers. For example, "Test1-Win2k12", "Test2-Win2k12" | Restart-Computer -VerboseOR(Get-Content C:\Servers.txt) | Restart-Computer -Verbose Few servers have dependencies on the other servers so main servers ... Read More

How to generate a strong password using PowerShell?

Chirag Nagrekar
Updated on 13-Jul-2020 05:39:25

461 Views

To generate a strong password with the PowerShell, we can use 8 or more characters password. In the below example, we are going to use the 8 character password, you can change the number of characters as per your convenience.This script you can bind into windows forms and provide it to the IT helpdesk to set the password for new users.In this example, we will use the Random integers between 33 and 126 and convert it to the Character, considering them they are the ASCII values for characters.You can find more about ASCII values in the table provided in the ... Read More

How to copy Items to the destination path with the differentcredentials in PowerShell?

Chirag Nagrekar
Updated on 13-Jul-2020 05:37:34

2K+ Views

To copy the items with the different credentials you need to use the credential parameter in the Copy-Item cmdlet.For example,Copy-Item C:\temp\* -Destination \Remoteshare\c$\temp -Credential (Get- Credential)Or$creds = (Get-Credential) Copy-Item C:\temp\* -Destination \Remoteshare\c$\temp -Credential $creds

Advertisements