Skip to content

Instantly share code, notes, and snippets.

@cjkoester
cjkoester / CSV_SelectColumns.ps1
Last active July 16, 2021 02:34
PowerShell script that loops through all CSV files in a folder, selects the desired columns, then outputs the files to a separate folder
# ------------------------------------------------------------------------
# NAME: CSV_SelectColumns.ps1
# AUTHOR: Chris Koester
# DATE: 11/2/2015
#
# KEYWORDS: CSV, text, text file
#
# COMMENTS: This script is used to loop through all CSV files in a folder,
# select the desired columns, then output the files to a separate folder.
#
@cjkoester
cjkoester / CheckOpenPort.ps1
Last active January 13, 2016 15:03
Check if a website and port is available with PowerShell
# Checks if a website and port are accessible
# Returns True if accessible and times out if not accessible
# Use port 80 for HTTP and 443 for HTTPS
$site = "google.com"
$port = "443"
$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.connect($site, $port)
$tcp.Connected
$url = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson"
$date = (Get-Date).ToString('yyyy-MM-dd')
$filePath = 'C:\Data\' + 'USGS Significant Earthquakes - Past Month' + ' ' + $date + '.js'
Invoke-RestMethod -Uri $url -Method GET -OutFile $filePath
using System;
using System.Net;
using System.Collections.Generic;
using System.Web.Script.Serialization;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
string json;
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);