Skip to content

Instantly share code, notes, and snippets.

View steviecoaster's full-sized avatar
🤠
It's a sweet day to write some Powershell

Stephen Valdinger steviecoaster

🤠
It's a sweet day to write some Powershell
View GitHub Profile
@steviecoaster
steviecoaster / Set-NonDomainRemoting.ps1
Created April 7, 2021 15:35
Quickly setup PSRemoting on Non-domain bound endpoints
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[String[]]
$TrustedHosts
)
begin {
if(-not (Test-WSMan)){
Enable-PSRemoting -Force
@steviecoaster
steviecoaster / ChocoAudit.ps1
Created March 9, 2021 19:39
Chocolatey Package Audit Report
choco list -lo --audit -r |
ConvertFrom-Csv -Delimiter '|' -Header Package,Version,InstalledBy,Domain,RequestedBy,InstallDate |
Select Package, Version,
@{Name='InstalledBy';Expression={$_.InstalledBy -replace ('User:','')}},
@{Name='Domain';Expression={$_.Domain -replace ('Domain:','')}},
@{Name='RequestedBy';Expression={$_.RequestedBy -replace ('Original User:','')}},
@{Name='InstallDate';Expression={$_.InstallDate -replace ('InstallDateUtc:','')}} |
ConvertTo-Html -Title "Chocolatey Package Audit" -PreContent "Machine: $env:COMPUTERNAME" > C:\temp\audit.htm
@steviecoaster
steviecoaster / Set-EnvironmentVariable.ps1
Last active February 17, 2021 22:44
Sets a System level environment variable to machine, currentuser, or process scope.
function Set-EnvironmentVariable {
<#
.SYNOPSIS
Sets a system environment variable
.DESCRIPTION
Sets an environment variable in either machine, currentuser, or process scope
.PARAMETER Scope
The scope to set variable too
{
"meta": {
"theme": "kendall"
},
"basics": {
"name": "Stephen Valdinger",
"label": "Customer Success Manager",
"picture": "https://avatars.githubusercontent.com/u/8674240?v=4",
"email": "[email protected]",
"phone": "330.503.7322",
@steviecoaster
steviecoaster / InternalizePackageIcons.ps1
Last active December 17, 2020 19:34
Internalize package icons for packages created with Chocolatey's Package Internalizer
<#
.SYNOPSIS
Internalize package icons for internalized packages
.EXAMPLE
$params = @{
InternalizerDownloadPath = 'C:\internalized\download\'
IconRepository = 'http://nexus.fabrikam.com:8081/repository/icons/'
PackageRepository = 'http://nexus.fabrikam.com:8081/repository/choco/'
}
@steviecoaster
steviecoaster / ChocoAnsible.ps1
Last active December 3, 2020 02:23
Get started with ansible using chocolatey
if(-not (Get-Command choco)){
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
choco install wsl wsl-ubuntu-2004 vscode vscode-powershell vscode-ansible -y
@steviecoaster
steviecoaster / Install-ChocolateyNotifyPackage.ps1
Last active November 19, 2020 21:41
Mobile push notifications when installing Chocolatey packages
Function Install-ChocolateyNotifyingPackage {
[cmdletBinding()]
param(
[parameter()]
[string]
$Package
)
process {
Function New-ChocolateyExtension {
<#
.SYNOPSIS
Generate chocolatey extension package from existing powershell module
.DESCRIPTION
Generate Chocolatey extension package from existing powershell module
.PARAMETER PowerShellModule
Use this to generate an extension from an existing, installed PowerShell module
$outdated = choco outdated -r | ConvertFrom-Csv -Delimiter '|' -Header 'PackageName', 'CurrentVersion', 'LatestVersion', 'Pinned'
$outdated = $outdated | Select-Object PackageName, CurrentVersion, LatestVersion, @{Name = 'Outdated'; Expression = { if ([version]$_.LatestVersion -gt [version]$_.CurrentVersion) { $true } else { $false } } }
$outdatedpackages = $outdated | Where-Object { $_.Outdated -eq $true } | Select-Object -First 4
$packageCollection = @()
$x = 24020
foreach ($odp in $outdatedpackages) {
@steviecoaster
steviecoaster / Remove-RemoteGitBranch.ps1
Created October 21, 2020 19:26
Quick PowerShell function to delete remote git branches
function Remove-RemoteGitBranch {
[cmdletbinding()]
param(
[Parameter(Mandatory = $true, Position = 0)]
[String]
$Branch
)
process {