Skip to content

Instantly share code, notes, and snippets.

View kilasuit's full-sized avatar

Ryan Yates kilasuit

View GitHub Profile
Initialize-SPPS -siteURL https://tenant.sharepoint.com/ -UserCredential $MYO365cred -IsOnline 1 -Verbose
Get-List "TestList" # Creates list variable
Get-ListFields -ListTitle $list.Title # Creates listfields variable
Get-Listviews -ListTitle $list.Title # Creates listviewIDs variable
$fieldstocopy = $listfields | Where-Object { $_.FromBaseType -notlike "True" }
@kilasuit
kilasuit / wmi_add-Member-Service.ps1
Created August 10, 2016 23:50
uses wmi to add service description to service objects (but isnt recommended)
$services = Get-Service -DisplayName Windows*
foreach ($service in $services) {
Add-Member -InputObject $service -MemberType NoteProperty -Name Description `
-Value $((Get-WmiObject Win32_service -Property name,displayname,status,description -Filter "name='$($service.Name)'").Description)
}
$services | Select Name,Displayname,Description
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate]
"SupportsUUP"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator]
"EnableUUPScan"=dword:00000001
@kilasuit
kilasuit / Install-ModuleFix.ps1
Created October 4, 2018 09:22
Install-ModuleFix.ps1
Function Install-ModuleFix {
<#
.SYNOPSIS
Describe purpose of "Install-ModuleFix" in 1-2 sentences.
.DESCRIPTION
Add a more complete description of what the function does.
.PARAMETER Module
Describe parameter -Module.
@kilasuit
kilasuit / Install-PS-No-IEX.ps1
Last active August 2, 2019 23:44
Showing a slightly safer way to install PowerShell instead of using IEX though still brings the same similar problems as IEX does
$wr = invoke-webrequest https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1
$sbuilder = [System.Text.StringBuilder]::new()
$sbuilder.AppendLine('function Install-ps {'}
$sbuilder.AppendLine($wr.content)
$sbuilder.AppendLine('}')
$sbuilder.AppendLine('')
$sbuilder.AppendLine('Install-ps -UseMSI -Preview') #Replace this with whatever switches you want to run instead from the ones available in the above script
$nsb = [Scriptblock]::Create($sbuilder.ToString())
. $nsb
@kilasuit
kilasuit / sampleprompt.ps1
Last active January 6, 2022 14:46
Powershell prompt
function Prompt
{
# Admin ?
if( (
New-Object Security.Principal.WindowsPrincipal (
[Security.Principal.WindowsIdentity]::GetCurrent())
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Admin-mark in WindowTitle
$Host.UI.RawUI.WindowTitle = "[Admin] " + $Host.UI.RawUI.WindowTitlep
Function Invoke-StarWarsTheme {
<#
.SYNOPSIS
PowerShell will sing the Star Wars theme.
.DESCRIPTION
Use [Console]::Beep to make some sound.
.EXAMPLE
@kilasuit
kilasuit / RY-BasicBootstrap.ps1
Last active January 4, 2024 19:09
Simple BootStrap for new machines
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -Scope LocalMachine
function Enable-PSTranscription {
$basePath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription"
if (-not (Test-Path $basePath)) { $null = New-Item $basePath –Force }
Set-ItemProperty $basePath -Name EnableTranscripting -Value 1
Set-ItemProperty $basePath -Name OutputDirectory -Value "$env:USERPROFILE\OneDrive\PSTranscripts\$env:COMPUTERNAME\"
Set-ItemProperty $basePath -Name EnableInvocationHeader -Value 1
$basePath = "HKLM:\Software\Policies\Microsoft\PowerShellCore\Transcription"
@kilasuit
kilasuit / Trace-Dependency.ps1
Created October 13, 2019 22:01 — forked from Jaykul/Trace-Dependency.ps1
Extract a list of commands used by a script or script command. Will warn about commands it can't identify and put them in global `$MissingCommands` variable.
#requires -Module Reflection
[CmdletBinding()]
param(
# The path to a script or name of a command
$Command,
# If you want to include private functions from a module, make sure it's imported, and pass the ModuleInfo here
[System.Management.Automation.PSModuleInfo]$ModuleScope = $(
Get-Module $Command -ListAvailable -ErrorAction SilentlyContinue | Get-Module -ErrorAction SilentlyContinue
),
@kilasuit
kilasuit / Profile
Created March 12, 2020 22:59
Example Question in Profile
function Request-YesOrNo {
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, Position=1)]
[string]$title="Confirm",
[Parameter(Mandatory=$true, Position=2)]
[string]$message="Are you sure?"