Chirag Nagrekar has Published 465 Articles

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

Chirag Nagrekar

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

How to Zip / Unzip files or folders using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 13-Jul-2020 05:36:01

2K+ Views

Now it is easy to ZIP or extract (unzip) the files or folders using PowerShell. PowerShell has added features of the Archive module (Microsoft.PowerShell.Archive) from PowerShell 5.1 version.If you have PowerShell older version (version 4.0 or less) then you can download and install the module from the website or through ... Read More

How to create a User Menu in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 03-Jul-2020 08:26:54

3K+ Views

When you are writing a script and if you want to provide the user to select one option among multiple values and based on it to execute the command, we can generally use the Switch command and for it, we will ask the user choice in the below script.There is ... Read More

How to get website SSL certificate validity dates with PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 03-Jul-2020 08:20:27

10K+ Views

SSL certificates are a very crucial part of the website. They play a key role in securing the exchange of information on both client and server sides by activating an HTTPS secure connection. In the below article with the PowerShell, we will get the certificate validity date (starting and expiry ... Read More

Explain Try/Catch/Finally block in PowerShell

Chirag Nagrekar

Chirag Nagrekar

Updated on 06-Jun-2020 13:07:37

7K+ Views

Try/Catch block in PowerShell is to handle the errors which are produced in the script. To be specific, the errors should be terminating errors. The Finally block in the PowerShell is not mandatory to write each time along with Try/Catch but it will be executed regardless the error occurs or ... Read More

How to use the ErrorAction parameter in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 27-May-2020 09:32:39

8K+ Views

Like ErrorActionPreference variable, ErrorAction parameter works similarly. ErrorAction parameter supported in Advance functions and most of the built-in cmdlets in PowerShell. It is useful to convert the non-terminating error to the terminating error and then you can handle them with try/catch blocks.Supported Values and Examples, Continue − This is the ... Read More

How to use the ErrorActionPreference variable in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 27-May-2020 09:30:49

5K+ Views

ErrorActionPreference variable in PowerShell is to control the non-terminating errors by converting them to terminating errors. Error handling depends upon which value you assign to $ErrorActionPreference variable.The values are as below.Continue − This is the default value of the variable and when the error occurs, an error is displayed in ... Read More

What is terminating and non-terminating errors in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 27-May-2020 09:27:29

1K+ Views

Powershell generates two types of errors when it executes script or commands. Terminating errors and Non-Terminating errors.Terminating error − This error generated by script, functions, or commands you create and it stops or halts the execution of the script so that the commands in the next lines can’t be executed. ... Read More

What is use of $error variable in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 27-May-2020 09:25:09

3K+ Views

Error variable in PowerShell is to view the errors generated in the current PowerShell session. We can say that the $Error variable is the container that stores all the errors and the latest error will be displayed first. For the example below, we will set the $Errorview to Category view ... Read More

What is the use of $Lastexitcode and $? Variable in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 27-May-2020 09:24:41

6K+ Views

$LastExitCode in Powershell is the number that represents the exit code/error level of the last script or application executed and $? (Dollar hook) also represents the success or the failure of the last command. In general, both represent the same but the output method is different. The first command output ... Read More

Advertisements