Skip to content

Instantly share code, notes, and snippets.

@ranadiprony
ranadiprony / Un-escape_Special_Characters.ps1
Created August 18, 2017 04:10
Un-Escape special Characters once converted to JSON object
$jsondata | ConvertTo-Json | % { [System.Text.RegularExpressions.Regex]::Unescape($_) } | Out-File "File.json" -Force
$jsonfile | ConvertTo-Json | % { [System.Text.RegularExpressions.Regex]::Unescape($_) } | Out-File "new.json"
@ranadiprony
ranadiprony / Compare-object.ps1
Created February 27, 2017 16:19
Compare Objects using Enumerable Class
## Will list the content present in Both the files
$file1 = import-csv -Path "C:\ps\output\obj1.csv"
$file2 = import-csv -Path "C:\ps\output\obj2.csv"
[linq.enumerable]::intersect( [object[]]($file1.name), [object[]]($file2.name) ) | Export-Csv -NoTypeInformation -Path "C:\ps\result\result.csv"
## will list the content present either in one of the files but not in both
$file1 = import-csv -Path "C:\ps\output\obj1.csv"
$file2 = import-csv -Path "C:\ps\output\obj2.csv"
$res = [Collections.Generic.HashSet[String]]( [string[]]($file1.name) )
$res.SymmetricExceptWith( [string[]]($file2.name) )
@ranadiprony
ranadiprony / Ignore-SelfSignedCerts.ps1
Last active January 30, 2017 16:14
Powershell Script for Ignoring the Self Signed Certificates
function Ignore-SelfSignedCerts
{
try
{
Write-Host "Adding TrustAllCertsPolicy type." -ForegroundColor White
Add-Type -TypeDefinition @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy
@ranadiprony
ranadiprony / New-Share.ps1
Created January 30, 2017 16:10
Creates New Share with Powershell
function New-Share {
param($Path, $Name)
try {
$ErrorActionPreference = 'Stop'
if ( (Test-Path $Path) -eq $false) {
$null = New-Item -Path $Path -ItemType Directory
}
net share $Name=$Path
}
catch {