Skip to content

Instantly share code, notes, and snippets.

@miteshsureja
miteshsureja / Import-csv.ps1
Created May 26, 2018 11:46
Import-Csv and Export-Csv PowerShell cmdlets
#export data using Export-CSV cmdlet
Get-EventLog Application -Newest 100 | Export-Csv logs.csv
Get-Content logs.csv
#import CSV data using Import-CSV cmdlet
#specify path
$path = "C:\PowerShell\logs.csv"
#import csv file and specify specific columns you want to import using -Header
$file = Import-Csv $path -Delimiter ","
#$file
@miteshsureja
miteshsureja / App.xaml.cs
Last active May 27, 2018 13:09
How to run single instance of an application using Mutex?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace WPFSingleInstanceApplication
@miteshsureja
miteshsureja / Program.cs
Last active July 5, 2023 12:27
How to execute PowerShell script or cmdlets from C# code?
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@miteshsureja
miteshsureja / Program.cs
Created June 16, 2018 06:55
Visitor Design Pattern
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisitorPattern
{
public enum Categories
{