Skip to content

Instantly share code, notes, and snippets.

View jwmoss's full-sized avatar
🤩
Stuck in a foreach loop

Jonathan Moss jwmoss

🤩
Stuck in a foreach loop
View GitHub Profile
#Requires -RunAsAdministrator
#Adapted from https://blogs.technet.microsoft.com/drew/2016/12/23/installing-remote-server-admin-tools-rsat-via-powershell/
$web = Invoke-WebRequest https://www.microsoft.com/en-us/download/confirmation.aspx?id=45520 -UseBasicParsing
$MachineOS = (Get-WmiObject Win32_OperatingSystem).Name
#Check for Windows Server 2012 R2
IF ($MachineOS -like "*Microsoft Windows Server*") {
<?xml version="1.0" encoding="UTF-8"?>
<unattend xmlns="urn:schemas-microsoft-com:setup" description="Auto unattend" author="pkgmgr.exe">
<servicing>
<package action="stage">
<assemblyIdentity buildType="release" language="neutral" name="Microsoft-Windows-RemoteServerAdministrationTools-Client-Package-TopLevel" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" version="10.0.16299.2"/>
<source location="." permanence="temporary"/>
</package>
</servicing>
</unattend>

Credit: Mark Kraus
Website: https://get-powershellblog.blogspot.com

Collection Type Guidance

When to use what

  • Use Arrays if you know the element types and have a fixed length and/or known-up-front collection size that will not change.
  • Use ArrayList if you have an unkown collection size with either unknown or mixed type elements.
  • Use a Generic List when know the type of the elements but not the size of the collection.
  • Use a HashTable if you are going to do key based lookups on a collection and don't know the object type of the elements.
  • Use a Dictionary<TKey, TValue> you are going to do key based lookups on a collection and you know the type of the elements.
  • Use a HashSet when you know the type of elements and just want unique values and quick lookups and assignmnets.
@jwmoss
jwmoss / Uninstall-Pester.ps1
Created April 17, 2019 15:38 — forked from nohwnd/Uninstall-Pester.ps1
Remove built-in version of Pester on Windows 10, and all other versions of Pester
#Requires -RunAsAdministrator
$modulePath = "C:\Program Files\WindowsPowerShell\Modules\Pester"
if (-not (Test-Path $modulePath)) {
"There is no Pester folder in $modulePath, doing nothing."
break
}
takeown /F $modulePath /A /R
icacls $modulePath /reset
@jwmoss
jwmoss / settings.json
Created April 17, 2020 13:46
VS Code Settings
{
"sync.gist": "4b86bbe471760ab9df8dfbbaf688e0f9",
"sync.autoUpload": true,
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.autofetch": true,
"sync.forceUpload": true,
"workbench.colorTheme": "PowerShell ISE",
"window.zoomLevel": 0
}
function Get-InstalledSoftware {
<#
.SYNOPSIS
Get all installed from the Uninstall keys in the registry.
.DESCRIPTION
Read a list of installed software from each Uninstall key.
This function provides an alternative to using Win32_Product.
.EXAMPLE
Get-InstalledSoftware
enum UserRight {
SeAssignPrimaryTokenPrivilege # Replace a process level token
SeAuditPrivilege # Generate security audits
SeBackupPrivilege # Back up files and directories
SeBatchLogonRight # Log on as a batch job
SeChangeNotifyPrivilege # Bypass traverse checking
SeCreateGlobalPrivilege # Create global objects
SeCreatePagefilePrivilege # Create a pagefile
SeCreatePermanentPrivilege # Create permanent shared objects
SeCreateSymbolicLinkPrivilege # Create symbolic links
#requires -Module PowerHTML
Function Get-PennyStockPumpDump {
[CmdletBinding()]
param (
[switch]
$All
)
$url = "https://pumpadump.com/"
{
"Tier1": [
"Endpoints"
],
"Tier2": [
"Agreement",
"Awarded",
"Cancer",
"Positive",
"Drug Trials",
{
"title": "List of Popular Screener Settings for FinViz",
"data": {
"sites": [
{
"name": "NightBefore",
"url": "https://finviz.com/screener.ashx?v=121&f=sh_curvol_o750,sh_price_u5,sh_relvol_o2,ta_change_u5&ft=4&o=price"
},
{
"name": "NightBeforeLowFloat",