Chirag Nagrekar has Published 465 Articles

How to change the Certificate's friendly name using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:37:42

1K+ Views

Suppose we know the Thumbprint of the certificate then we can use the below command to update or change the certificate's friendly name.Example$cert = Get-ChildItem `    -Path Cert:\LocalMachine\My\43E6035D120EBE9ECE8100E8F38B85A9F1C1140F$cert.FriendlyName = "mysitecert"The above command will update the certificate-friendly name to "mysitecert". If you don't know the thumbprint or how to retrieve it, you can use different ... Read More

How to install a certificate to the certificate store using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:33:58

20K+ Views

To install the certificate using PowerShell, we need to use the Import-Certificate command. For example, we have a certificate stored at the location C:\temp\Mycert.cer and we need to install it in the Personal store of the local machine.ExampleImport-Certificate -FilePath C:\Temp\Mycert.cer `    -CertStoreLocation Cert:\LocalMachine\My\You can also use the below method.PS C:\> Set-Location Cert:\LocalMachine\My\ PS Cert:\LocalMachine\My\> Import-Certificate -FilePath C:\Temp\Mycert.cerTo install a ... Read More

How to Export a certificate from a certificate store using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:33:34

3K+ Views

To export or download a certificate from the certificate store using PowerShell, we need to use the command Export-Certificate.First, you need to get the certificate details from the store. If you know the thumbprint, you can directly get the certificate details using the thumbprint and then use that details to ... Read More

How to create a self-signed certificate using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:33:12

4K+ Views

To create a self-signed certificate there are various methods like OpenSSL, IIS, PowerShell, etc. Here, we will see how we can create a self-signed certificate with PowerShell.To create a self-signed certificate with PowerShell, we need to use the New-SelfSignedCertificate command. When you create a self-signed certificate manually, you need to ... Read More

How to create a dummy file of any size with PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:32:51

3K+ Views

To create any dummy file of having any size with PowerShell, we can use the below command.Example$f = new-object System.IO.FileStream c:\temp\test.dat,  Create,  ReadWrite $f.SetLength(50MB) $f.Close()The above command will create 50MB of Test.dat dummy file in the C:\temp. Such files are used for testing purposes.Read More

How to get the default Documents from the IIS site using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:32:29

420 Views

To get the default documents stored on the IIS default website page, you can use the below command.ExampleGet-WebConfigurationProperty -Filter //defaultDocument/files/add    -PSPath 'IIS:\Sites\Default Web Site' -Name value `    | select valueOutputValue ----- Default.htm Default.asp index.htm index.html iisstart.htmTo check if the Default document contains a specific file, (Get-WebConfigurationProperty -Filter //defaultDocument/files/add ... Read More

How to copy only updated or newer files with PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Mar-2021 07:31:41

8K+ Views

To copy only updated or newer files with PowerShell, we can use Copy-Item with some logic in the script that to check if the files exist on the destination folder if not then copy that file and if yes then compare the timestamp and copy the latest file. This would ... Read More

How to update the specific node of the XML file using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 01-Mar-2021 12:09:27

7K+ Views

To update the specific XML node using PowerShell, we first need to select that node with the attribute with SelectSingleNode() method.We have below the XML file from the link stored in SampleXml.XML on C:\Temp location.https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms762271(v=vs.85)In this example, we are going to update Autor and Genre properties of the Book having attribute Id = ‘bk102’$xml=[xml](Get-Content ... Read More

How to check Azure VM Power state using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 01-Mar-2021 10:51:55

7K+ Views

To check if the VMs are running, deallocated, or stopped using PowerShell, we need to use the - Status parameter.If you write only the Get-AzVM command to get the VM details, it won’t show up the Azure VM power status default.ExampleTo check the Azure VM Power Status, Get-AzVM -statusOutput The above ... Read More

How to get the list of shared folders using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 01-Mar-2021 10:49:21

6K+ Views

Get-SmbShare gives all the shared folders on the local system.PS C:\Temp> Get-SmbShare Name    ScopeName    Path       Description ----    ---------    ----       ----------- ADMIN$    *       C:\Windows    Remote Admin C$        *       C:\ Default ... Read More

Advertisements