Skip to content

Instantly share code, notes, and snippets.

@roysubs
roysubs / notes-downloading.ps1
Created Nov 29, 2019
Notes: download methods
View notes-downloading.ps1
# How do I download URL content using Get-Content in PowerShell Script?
# Assumes that you have a URL on each line in C:\Urls.txt. It will put the files in a folder at C:\UrlOutput. If that’s not where you want them, just change the $OutputFolder variable value appropriately.
$Urls = Get-Content "C:\Urls.txt"
$OutputFolder = "C:\UrlOutput"
if(!(Test-Path $OutputFolder)){ New-Item -ItemType Directory -Path $OutputFolder -Force | Out-Null }
for ($x = 0; $x -lt ($Urls | measure | select -expand Count); $x++)
{
@roysubs
roysubs / Custom-Tools.psm1
Last active Jun 11, 2021
Custom-Tools Module to copy into C:\Program Files\WindowsPowerShell\Modules\Custom-Tools
View Custom-Tools.psm1
####################
#
# Custom-Tools.psm1
# Current Version: 2020-10-24
#
# Module is installed to the Module folder visible to all users (but can only be modified by Administrators):
# C:\Program Files\WindowsPowerShell\Modules\Custome-Tools
#
# The Module contains only functions to access on demand as required.
# mods : View all Modules installed in all PSModulePath folders.
@roysubs
roysubs / ProfileExtensions.ps1
Last active Nov 12, 2020
Called from $profile to add functionality to console settings
View ProfileExtensions.ps1
########################################
#
# ProfileExtensions.ps1
#
# The profile extensions is normally called by a single line that is added to
# the end of $Profile, or can be dotsourced manually if required.
#
# The handler line in $Profile performs the following:
# a) It check if $($Profile)_extensions.ps1 exists, if not download it.
# b) It then runs (dotsource) $($Profile)_extensionss.ps1.
@roysubs
roysubs / BeginSystemConfig.ps1
Last active Apr 20, 2021
Run this script using iex (Invoke-Expression) to configure apps, create profile-extensions, install modules and other custom setup
View BeginSystemConfig.ps1
########################################
#
# BeginSystemConfig.ps1
# iex ((New-Object System.Net.WebClient).DownloadString('https://bit.ly/2R7znLX'));
#
# Author: roysubs@hotmail.com
#
# 2019-11-25 Initial setup
# 2020-10-19 Latest Version
#
@roysubs
roysubs / Git-dump
Last active Dec 9, 2019
Git basics dump ...
View Git-dump
Just some notes on git ...
Install git from git-scm.com
https://www.youtube.com/watch?v=SWYqp7iY_Tc
https://guides.github.com/activities/hello-world/ # Quick guide from GitHub
Create folder and put stuff in it.
# git init
# git add <filename> # add <filename>
# git add . # add all files in folder
# git status # show added / not added / changed files
@roysubs
roysubs / Basic-Tools.psm1
Last active Nov 28, 2019
PowerShell Module with constantly updated set of general tools
View Basic-Tools.psm1
####################
# Isolate as much as possible away from $profile. All functions should be in Modules whenever possible
####################
# Module: Common-Tools
# Collection of helper functions to constantly update
function syntax($cmd) { Get-Command $cmd -Syntax } # or (Get-Command $cmd).Definition
function parameter($cmd, $parameter) { Get-Help $cmd -Parameter $parameter }
function examples($cmd) { Get-Help $cmd -Examples } # or (Get-Command $cmd).Definition
@roysubs
roysubs / Get-Gist.ps1
Last active Nov 24, 2019
Get-Gist, not working yet
View Get-Gist.ps1
# https://github.com/dfinke/Posh-Gist
# Get-Gist
# Copy of the Gist-Functions, with focus on Get-Gist
# You need a GitHub account to post a gist, this does not support anonymous posts.
# Remember that the param statement should be the first one in a PowerShell script.
param(
[Parameter(Mandatory)]
[string]$User,
@roysubs
roysubs / Send-Gist.ps1
Created Nov 24, 2019
Description for Send-Gist.ps1
View Send-Gist.ps1
# https://github.com/dfinke/Posh-Gist
# Send-Gist
# Copy of the Gist-Functions, with focus on Send-Gist
# You need a GitHub account to post a gist, this does not support anonymous posts.
# Remember that the param statement should be the first one in a PowerShell script.
param([string]$Path, [string]$Description)