Export Certificate from Certificate Store using PowerShell

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

4K+ 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 export the certificate.Example$cert = (Get-ChildItem  Cert:\LocalMachine\My\43E6035D120EBE9ECE8100E8F38B85A9F) Export-Certificate -Cert $cert -Type CERT -FilePath C:\Temp\Mycert.cerIn the above example, we are exporting the certificate from the LocalMachine -> Personal Store. You can choose a different path. Here, the certificate would be exported to the C:\temp\MyCert.cer. You can use the different types like P7B, SST to export the certificate. Alternatively, you ... Read More

Create Self-Signed Certificate Using PowerShell

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

5K+ 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 give few properties like DNSName, FriendlyName, Certificate start date, expiry date, Subject, a path of the certificate. Similarly, you can use those properties for this command to create it. Not all properties are mandatory.ExampleNew-SelfSignedCertificate `    -CertStoreLocation Cert:\LocalMachine\My `    -DnsName "testdomain.local" -VerboseOutputPSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\My Thumbprint             ... Read More

Create Dummy File of Any Size with PowerShell

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

4K+ 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.

Get Default Documents from IIS Site Using PowerShell

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

555 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 -PSPath 'IIS:\Sites\Default Web Site' -Name value).value -contains 'iisstart.htm'The above command checks if the IIS default website contains any iisstart.htm on the default document page.You can also use another website instead of using 'Default Web site'. To get the default documents file at the IIS level, (Get-WebConfigurationProperty -Filter //defaultDocument/files/add -PSPath 'IIS:\' ... Read More

Copy Only Updated or Newer Files with PowerShell

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

10K+ 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 be tricky because we need to write several lines of code for it.But Windows support xCopy utility which can directly copy the newer or updated files and this utility we can accommodate in PowerShell as well.xCopy uses a switch called /d. its actual syntax is, Syntax/d [:MM-DD-YYYY]This means if the date ... Read More

Calculate Root Mean Square of Image Pixels Using Pillow Library

Prasad Naik
Updated on 18-Mar-2021 07:19:49

828 Views

In this program, we will calculate the rms (root mean square) of all the pixels in each channel using the Pillow library. There are a total three channels in an image and therefore, we will get a list of three values.Original ImageAlgorithmStep 1: Import the Image and ImageStat libraries. Step 2: Open the image. Step 3: Pass the image to the stat function of the imagestat class. Step 4: Print the root mean square of the pixels.Example Codefrom PIL import Image, ImageStat im = Image.open('image_test.jpg') stat = ImageStat.Stat(im) print(stat.rms)Output[104.86876722259062, 96.13661429330132, 91.8480515464677]

Calculate Variance of Pixels for Each Band in an Image using Pillow

Prasad Naik
Updated on 18-Mar-2021 07:19:29

1K+ Views

In this program, we will calculate the variance of all the pixels in each channel using the Pillow library. There are a total three channels in an image and therefore, we will get a list of three values.Original ImageAlgorithmStep 1: Import the Image and ImageStat libraries. Step 2: Open the image. Step 3: Pass the image to the stat function of the imagestat class. Step 4: Print the variance of the pixels.Example Codefrom PIL import Image, ImageStat im = Image.open('image_test.jpg') stat = ImageStat.Stat(im) print(stat.var)Output[5221.066590958682, 4388.697801428673, 4291.257706548981]

Calculate Standard Deviation of Image Pixels Using Pillow Library

Prasad Naik
Updated on 18-Mar-2021 07:19:06

1K+ Views

In this program, we will calculate the standard deviation of all the pixels in each channel using the Pillow library. There are total 3 channels in an image and therefore we will get a list of three values.Original ImageAlgorithmStep 1: Import Image and ImageStat libraries. Step 2: Open the image. Step 3: Pass the image to the stat function of the imagestat class. Step 4: Print the standard deviation of the pixels.Example Codefrom PIL import Image, ImageStat im = Image.open('image_test.jpg') stat = ImageStat.Stat(im) print(stat.stddev)Output[72.25694839223894, 66.24724750077299, 65.50769196475312]

Apply Rank Filter to an Image Using the Pillow Library

Prasad Naik
Updated on 18-Mar-2021 07:16:46

312 Views

In this program, we will blur an image using a rank filter. The ImageFilter class in the pillow library contains a function called RankFilter() which helps to apply the rank filter. It takes two parameters, size of the kernel and rank. Rank is 0 for a min filter, size*size/2 for a median filter and size*size-1 for a max filter.Original ImageAlgorithmStep 1: Import Image and ImageFilter from Pillow. Step 2: Open the image. Step 3: Call the rankfilter() method and specify the size and rank. Step 4: Display the output.Example Codefrom PIL import Image, ImageFilter im = Image.open('image_test.jpg') im1 = ... Read More

Apply Box Blur to an Image Using the Pillow Library

Prasad Naik
Updated on 18-Mar-2021 07:01:21

429 Views

In this program, we will blur an image using a Box filter. The ImageFilter class in the pillow library contains a function called BoxBlur() which helps to apply the box blur filter. It takes only one parameter that is blur radius.Original ImageAlgorithmStep 1: Import Image and ImageFilter from Pillow. Step 2: Open the image. Step 3: Call the boxblur() method and specify the radius. Step 4: Display the output.Example Codefrom PIL import Image, ImageFilter im = Image.open('image_test.jpg') im1 = im.filter(ImageFilter.BoxBlur(radius = 7)) im1.show()Output

Advertisements