├── .gitignore ├── Modules ├── PowershellForGit │ ├── GitFlow.psm1 │ ├── GitConfig.psm1 │ ├── GitFlowHotFix.psm1 │ ├── GitFlowRelease.psm1 │ ├── GitEnvironments.psm1 │ ├── GitFiles.psm1 │ ├── GitFlowFeature.psm1 │ └── GitCommits.psm1 ├── PowershellForOpenSSL │ └── Hashes.psm1 ├── AzureDevOps │ ├── AzureDevOpsRepository.psm1 │ ├── AzureDevOps.psd1 │ └── AzureDevOpsProjects.psm1 ├── DateTime │ ├── README.md │ ├── DateTime.psd1 │ └── DateTime.psm1 ├── OctopusDeploy │ ├── OctopusServer.psm1 │ ├── OctopusEnvironments.psm1 │ ├── OctopusProjects.psm1 │ └── OctopusDeploy.psd1 ├── WebCredential │ ├── README.md │ ├── WebCredential.psd1 │ └── docs │ │ └── Remove-WebCredential.md ├── Networking │ ├── Reset-NetworkAdapters.ps1 │ ├── IPerf.psm1 │ ├── Wireshark.psm1 │ ├── Watch-DefaultGatewayChangeVpn.ps1 │ ├── BindTools.psm1 │ └── PacketCapture.psm1 ├── Drive │ ├── Drive.psd1 │ └── Drive.psm1 ├── Editors │ ├── Editors.psd1 │ └── Editors.psm1 ├── Node │ ├── Node.psd1 │ └── Node.psm1 ├── SqlServer │ ├── SqlServer.psd1 │ └── SqlServer.psm1 ├── Logging │ ├── Logging.psd1 │ └── Logging.psm1 ├── VirtualBaseDisk │ ├── README.md │ ├── VirtualBaseDisk.psd1 │ └── docs │ │ ├── Get-WindowsImagesInISO.md │ │ └── Get-WindowsImagesInWIM.md ├── PSModules │ ├── README.md │ ├── PSModules.psd1 │ └── docs │ │ ├── Reset-Module.md │ │ ├── Restart-Module.md │ │ └── Update-InstalledModules.md ├── UI │ ├── UI.psd1 │ └── Pin-Taskbar.ps1 ├── Elevation │ └── Elevation.psd1 ├── MongoDB │ ├── MongoDB.psd1 │ └── MongoDB.psm1 ├── LinuxSubsystem │ └── LinuxSubsystem.psd1 ├── PowershellForDocker │ └── docs │ │ ├── Test-Docker.md │ │ ├── Find-Docker.md │ │ ├── Switch-DockerLinuxEngine.md │ │ ├── Resume-DockerCompose.md │ │ ├── Switch-DockerWindowsEngine.md │ │ ├── Test-DockerCompose.md │ │ ├── Test-DockerLinuxEngine.md │ │ ├── Suspend-DockerCompose.md │ │ ├── Find-DockerCompose.md │ │ ├── Get-DockerServerEngine.md │ │ ├── Invoke-DebianContainer.md │ │ ├── Test-DockerWindowsEngine.md │ │ ├── Invoke-Dive.md │ │ ├── Get-DockerDiskUsage.md │ │ ├── Stop-DockerCompose.md │ │ ├── Get-RunningDockerContainers.md │ │ ├── Optimize-DockerVolume.md │ │ ├── Remove-DockerVolume.md │ │ ├── Optimize-DockerNetwork.md │ │ ├── Remove-DockerNetwork.md │ │ ├── Get-DockerContainerIds.md │ │ ├── Invoke-DockerContainerShell.md │ │ ├── Connect-DockerContainer.md │ │ ├── Pop-DockerCompose.md │ │ ├── Get-DockerVolume.md │ │ ├── Start-DockerCompose.md │ │ ├── Read-DockerCompose.md │ │ ├── Get-DockerContainerNames.md │ │ ├── Pop-DockerImage.md │ │ ├── Get-DockerMountPoint.md │ │ ├── Start-DockerContainer.md │ │ ├── Remove-DockerImage.md │ │ ├── Invoke-DockerLog.md │ │ ├── Disconnect-DockerNetwork.md │ │ ├── Get-DockerContainerIPAddress.md │ │ ├── Get-DockerContainerState.md │ │ ├── Stop-DockerContainer.md │ │ ├── New-DockerNfsVolume.md │ │ ├── Get-FilePathForContainer.md │ │ └── Get-PathForContainer.md ├── PowershellForVirtualBox │ └── PowershellForVirtualBox.psd1 ├── Kubernetes │ ├── Kubernetes.psd1 │ ├── kubescape.psm1 │ └── Kubernetes.psm1 ├── RemoteRDP │ └── RemoteRDP.psd1 ├── Chocolatey │ └── Chocolatey.psd1 ├── LogStash │ └── LogStash.psd1 ├── VirtualMachines │ └── VirtualMachines.psd1 ├── DotNet │ └── DotNet.psd1 ├── PowershellForAnsible │ ├── AnsibleVault.psm1 │ ├── AnsibleInventory.psm1 │ ├── docs │ │ ├── Get-AnsibleConfigFile.md │ │ ├── Edit-AnsibleVault.md │ │ ├── Export-AnsibleFacts.md │ │ └── Confirm-AnsiblePlaybookSyntax.md │ └── README.md ├── Versioning │ └── Versioning.psd1 ├── PSExtensions │ ├── README.md │ ├── docs │ │ ├── Edit-Profile.md │ │ ├── Update-Profile.md │ │ ├── Get-Profile.md │ │ ├── Update-MyProfile.md │ │ ├── Test-IsNonInteractive.md │ │ ├── Get-LastExecutionTime.md │ │ ├── Import-Assembly.md │ │ ├── Remove-AliasesFromScript.md │ │ ├── Test-PowershellVerb.md │ │ └── Get-PowerShellVerbs.md │ └── PSExtensions.psd1 ├── VirtualLab │ └── VirtualLab.psd1 ├── NuGet │ └── NuGet.psd1 ├── VisualStudio │ └── VisualStudio.psd1 ├── VirtualDevelopment │ ├── VirtualDevelopment.psd1 │ └── docs │ │ └── New-DevVM.md ├── TextFormatting │ ├── TextFormatting.psd1 │ └── TextFormatting.psm1 ├── OperatingSystem │ └── OperatingSystem.psd1 ├── Code │ ├── Code.psd1 │ └── Code.psm1 ├── ElasticSearch │ ├── ElasticSearch.psd1 │ ├── ElasticSearchCluster.psm1 │ └── ElasticSearchIndex.psm1 ├── OpenSSH │ ├── OpenSSH.psd1 │ └── OpenSSHConfig.psm1 ├── TeamCity │ ├── TeamCityUsers.psm1 │ └── TeamCity.psd1 └── FileSystem │ └── FileSystem.psd1 ├── .editorconfig ├── choco └── dcjulian29.psmodules │ ├── thirdparty.json │ ├── remove.json │ ├── mine.json │ ├── chocolateyPackage.nuspec │ └── build.ps1 ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .vscode └── settings.json ├── .gitattributes └── notes.md /.gitignore: -------------------------------------------------------------------------------- 1 | package.nuspec 2 | *.nupkg 3 | _tbd/ 4 | Modules/**/todo 5 | .packages/ 6 | .tools/ 7 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitFlow.psm1: -------------------------------------------------------------------------------- 1 | function Initialize-GitFlow { 2 | & "$(Find-Git)" flow init -d 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{ps1,psd1,psm1}] 2 | indent_style = space 3 | indent_size = 2 4 | insert_final_newline = true 5 | trim_trailing_whitespace = true 6 | -------------------------------------------------------------------------------- /choco/dcjulian29.psmodules/thirdparty.json: -------------------------------------------------------------------------------- 1 | [ 2 | "Microsoft.PowerShell.SecretManagement", 3 | "Microsoft.PowerShell.SecretStore", 4 | "PSScriptAnalyzer" 5 | ] 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | rebase-strategy: "auto" 9 | -------------------------------------------------------------------------------- /Modules/PowershellForOpenSSL/Hashes.psm1: -------------------------------------------------------------------------------- 1 | function Get-AvailableOpenSslDigestAlgorithms { 2 | Invoke-OpenSsl "list -digest-algorithms" 3 | } 4 | 5 | Set-Alias -Name "Get-OpenSslDigestAlgorithms" -Value Get-AvailableOpenSslDigestAlgorithms 6 | -------------------------------------------------------------------------------- /Modules/AzureDevOps/AzureDevOpsRepository.psm1: -------------------------------------------------------------------------------- 1 | function Get-AdoRepository { 2 | param ( 3 | [Alias("Name")] 4 | [string] $Id 5 | ) 6 | 7 | if ($Id) { 8 | Invoke-AzureDevOpsApi "git/repositories/$Id" 9 | } else { 10 | (Invoke-AzureDevOpsApi "git/repositories").value 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Modules/DateTime/README.md: -------------------------------------------------------------------------------- 1 | 2 | # DateTime ![Version](https://img.shields.io/myget/dcjulian29-powershell/v/DateTime) 3 | 4 | This module provides functions to deal with date and time. Other functions have been spread to various other modules and this module will become the new home for those functions as well as any new functions on the topic. 5 | 6 | ## Functions 7 | 8 | - [Show-Calendar](docs/Show-Calendar.md) 9 | -------------------------------------------------------------------------------- /Modules/OctopusDeploy/OctopusServer.psm1: -------------------------------------------------------------------------------- 1 | function Get-OctopusServerUptime { 2 | $info = Invoke-OctopusApi "serverstatus/system-info" 3 | 4 | if ($info) { 5 | return $info.Uptime 6 | } 7 | } 8 | 9 | function Get-OctopusServerVersion { 10 | $info = Invoke-OctopusApi "serverstatus/system-info" 11 | 12 | if ($info) { 13 | return $info.Version 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Modules/OctopusDeploy/OctopusEnvironments.psm1: -------------------------------------------------------------------------------- 1 | function Get-OctopusEnvironments { 2 | Invoke-OctopusApi "Environments/all" 3 | } 4 | 5 | function Get-OctopusEnvironment { 6 | param ( 7 | [Parameter(Mandatory = $true)] 8 | [string] $Name 9 | ) 10 | 11 | $environments = Get-OctopusEnvironments 12 | 13 | return $environments | Where-Object { $_.Name -eq $Name} 14 | } 15 | -------------------------------------------------------------------------------- /Modules/WebCredential/README.md: -------------------------------------------------------------------------------- 1 | # WebCredential ![Version](https://img.shields.io/myget/dcjulian29-powershell/v/WebCredential) 2 | 3 | Provides the ability to store and retrieve username and passwords in the Web Credentials store on Windows. 4 | 5 | ## Functions 6 | 7 | - [Get-WebCredential](docs/Get-WebCredential.md) 8 | - [Remove-WebCredential](docs/Remove-WebCredential.md) 9 | - [Set-WebCredential](docs/Set-WebCredential.md) 10 | -------------------------------------------------------------------------------- /Modules/Networking/Reset-NetworkAdapters.ps1: -------------------------------------------------------------------------------- 1 | function Reset-NetworkAdapters { 2 | $adapters = Get-NetAdapter | Where-Object { $_.Status -ne 'Disconnected' } 3 | 4 | foreach ($adapter in $adapters) { 5 | Write-Output "Restarting $($adapter.Name) interface..." 6 | $adapter | Restart-NetAdapter 7 | 8 | Start-Sleep 2 9 | 10 | $adapter | Set-DnsClientServerAddress -ResetServerAddresses 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Modules/Drive/Drive.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2204.19.1' 3 | GUID = '96fae4b3-b93d-467c-bbe7-0da5124f171f' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Drive.psm1' 7 | NestedModules = @() 8 | TypesToProcess = @() 9 | FormatsToProcess = @() 10 | FunctionsToExport = @( 11 | "Get-UsbDrives" 12 | "Get-FixedDrives" 13 | "Get-Drives" 14 | ) 15 | AliasesToExport = @() 16 | } 17 | -------------------------------------------------------------------------------- /Modules/Editors/Editors.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2305.18.1' 3 | GUID = '2cd0c771-ed8b-48bc-b6bc-be8540c915e4' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Editors.psm1' 7 | NestedModules = @() 8 | TypesToProcess = @() 9 | FormatsToProcess = @() 10 | FunctionsToExport = @( 11 | "Invoke-NotePadEditor" 12 | ) 13 | AliasesToExport = @( 14 | "notepad" 15 | "np" 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /Modules/Node/Node.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2204.19.1' 3 | GUID = '2c8d7516-d46b-4b08-b9a0-ab87448b8f13' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Node.psm1' 7 | NestedModules = @() 8 | TypesToProcess = @() 9 | FormatsToProcess = @() 10 | FunctionsToExport = @( 11 | "Get-NodeVersion" 12 | "Start-NodePackageManager" 13 | "Start-Node" 14 | "Test-Node" 15 | ) 16 | AliasesToExport = @( 17 | "npm" 18 | "node" 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /Modules/Editors/Editors.psm1: -------------------------------------------------------------------------------- 1 | function Invoke-NotePadEditor { 2 | param( 3 | [Parameter(Mandatory=$true)] 4 | [ValidateNotNullOrEmpty()] 5 | [ValidateScript({ Test-Path $(Resolve-Path $_) })] 6 | [string]$Path 7 | ) 8 | 9 | $Path = (Resolve-Path $Path).Path 10 | $notePad = Find-ProgramFiles 'Notepad++\notepad++.exe' 11 | $param = "-nosession $Path" 12 | 13 | Start-Process -FilePath $notePad -ArgumentList $param 14 | } 15 | 16 | Set-Alias notepad Invoke-NotePadEditor 17 | Set-Alias np Invoke-NotePadEditor 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "Adcs", 4 | "ADSI", 5 | "choco", 6 | "cmdletbinding", 7 | "contoso", 8 | "dcjulian", 9 | "devvm", 10 | "dism", 11 | "firstdc", 12 | "HKLM", 13 | "hyperv", 14 | "LNXDEV", 15 | "MSVM", 16 | "myvm", 17 | "Nsense", 18 | "NTFS", 19 | "pshellcmd", 20 | "pshellexe", 21 | "psobject", 22 | "Robocopy", 23 | "Rsat", 24 | "sshellc", 25 | "TCPIP", 26 | "UEFI", 27 | "unattend", 28 | "Vhdx", 29 | "vmconnect", 30 | "vmms" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /Modules/SqlServer/SqlServer.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'SqlServer.psm1' 3 | ModuleVersion = '2020.2.15.1' 4 | GUID = 'd55983c8-b268-42a7-b59a-d4396054f223' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Find-SqlCmd" 11 | "Invoke-SqlCmd" 12 | "Invoke-SqlFile" 13 | "Register-SqlCmdSqlCredentials" 14 | ) 15 | AliasesToExport = @( 16 | "mssql-start" 17 | "mssql-stop" 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /Modules/OctopusDeploy/OctopusProjects.psm1: -------------------------------------------------------------------------------- 1 | function Get-OctopusProject { 2 | param ( 3 | [Parameter(Mandatory = $true)] 4 | [string] $Name 5 | ) 6 | 7 | $projects = Get-OctopusProjects 8 | 9 | return $projects | Where-Object { $_.Name -eq $Name} 10 | } 11 | 12 | function Get-OctopusProjectById { 13 | param ( 14 | [Parameter(Mandatory = $true)] 15 | [string] $Id 16 | ) 17 | 18 | Invoke-OctopusApi "projects/$Id" 19 | } 20 | 21 | function Get-OctopusProjects { 22 | Invoke-OctopusApi "projects/all" 23 | } 24 | -------------------------------------------------------------------------------- /Modules/Logging/Logging.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2103.20.1' 3 | GUID = '6aa69e5b-f92d-41ba-947b-7840504d31da' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Logging.psm1' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Get-LogFolder" 11 | "Get-LogFileName" 12 | "Optimize-LogFolder" 13 | "Start-ApplicationTranscript" 14 | "Write-Log" 15 | ) 16 | AliasesToExport = @( 17 | "Stop-ApplicationTranscript" 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /choco/dcjulian29.psmodules/remove.json: -------------------------------------------------------------------------------- 1 | [ 2 | "7Zip4Powershell", 3 | "AnsibleVault", 4 | "BurntToast", 5 | "CertificateAuthority", 6 | "GitlabCli", 7 | "Go", 8 | "Grok", 9 | "Lability", 10 | "Microsoft.PowerShell.ConsoleGuiTools", 11 | "MicrosoftTeams", 12 | "NtpTime", 13 | "Path", 14 | "platyPS", 15 | "Posh-ACME", 16 | "PowerShellForGitHub", 17 | "PsIni", 18 | "PSParseHTML", 19 | "PSRule", 20 | "PSWriteExcel", 21 | "PSWriteHTML", 22 | "PSWritePDF", 23 | "PSWriteWord", 24 | "RobocopyPS", 25 | "SHiPS", 26 | "Trackyon.Utils", 27 | "VirtualBox", 28 | "VSTeam" 29 | ] 30 | -------------------------------------------------------------------------------- /Modules/Drive/Drive.psm1: -------------------------------------------------------------------------------- 1 | Function Get-UsbDrives 2 | { 3 | Get-WmiObject Win32_DiskDrive ` 4 | | where { $_.InterfaceType -eq 'USB' } ` 5 | | Select-Object DeviceId, InterfaceType, Status, SerialNumber, Model, Size, MediaType 6 | } 7 | 8 | Function Get-FixedDrives 9 | { 10 | Get-WmiObject Win32_DiskDrive ` 11 | | where { $_.InterfaceType -ne 'USB' } ` 12 | | Select-Object DeviceId, InterfaceType, Status, SerialNumber, Model, Size, MediaType 13 | } 14 | 15 | Function Get-Drives 16 | { 17 | Get-WmiObject Win32_LogicalDisk ` 18 | | Select-Object DeviceID, ProviderName, Size, FreeSpace ` 19 | | Format-List 20 | } 21 | -------------------------------------------------------------------------------- /Modules/VirtualBaseDisk/README.md: -------------------------------------------------------------------------------- 1 | # VirtualBaseDisk ![Version](https://img.shields.io/myget/dcjulian29-powershell/v/VirtualBaseDisk) 2 | 3 | Provides the ability to interact with ISO and WIM files to create a Hyper-V 4 | disk that can then be used as a differencing disk for storing the changes 5 | made by the guest operating system (OS). 6 | 7 | ## Functions 8 | 9 | - [Get-WindowsImagesInISO](docs/Get-WindowsImagesInISO.md) 10 | - [Get-WindowsImagesInWIM](docs/Get-WindowsImagesInWIM.md) 11 | - [New-BaseServerVhdxDisks](docs/New-BaseServerVhdxDisks.md) 12 | - [New-BaseVhdxDisk](docs/New-BaseVhdxDisk.md) 13 | - [New-DevBaseVhdxDisk](docs/New-DevBaseVhdxDisk.md) 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.md text 4 | *.gitattributes text 5 | 6 | *.ps1 text eol=crlf 7 | *.psm1 text eol=crlf 8 | *.psd1 text eol=crlf 9 | *.psc1 text eol=crlf 10 | *.ps1xml text eol=crlf 11 | *.clixml text eol=crlf 12 | *.xml text eol=crlf 13 | *.txt text eol=crlf 14 | 15 | *.dll binary 16 | *.exe binary 17 | *.svg binary 18 | 19 | # npm now seems to be insisting on LF - see https://github.com/npm/npm/issues/17161 20 | package.json text eol=lf 21 | package-lock.json text eol=lf 22 | -------------------------------------------------------------------------------- /Modules/PSModules/README.md: -------------------------------------------------------------------------------- 1 | # PSModules ![Version](https://img.shields.io/myget/dcjulian29-powershell/v/PSModules) 2 | 3 | A collection of utilities, commands, and functions specific to Powershell modules. 4 | 5 | ## Functions 6 | 7 | ### [Get-InstalledModuleReport](docs/Get-InstalledModuleReport.md) 8 | 9 | ### [Reset-Module](docs/Reset-Module.md) 10 | 11 | ### [Restart-Module](docs/Restart-Module.md) 12 | 13 | ### [Update-InstalledModules](docs/Update-InstalledModules.md) 14 | 15 | ### [Update-PreCompiledAssemblies](docs/Update-PreCompiledAssemblies.md) 16 | 17 | ## Aliases 18 | 19 | ### [Reload-Module](docs/Restart-Module.md) 20 | 21 | ### [Unload-Module](docs/Update-Profile.md) 22 | -------------------------------------------------------------------------------- /Modules/UI/UI.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'UI.psm1' 3 | ModuleVersion = '2301.18.1' 4 | GUID = '64252dac-92cf-41fb-9ef7-94e1a42c56ac' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Get-BingWallpaper" 11 | "Get-Weather" 12 | "Read-MultiLineInput" 13 | "Select-Item" 14 | "Set-WindowTitle" 15 | "Set-BingDesktopWallpaper" 16 | "Set-BingWallpaperScheduledTask" 17 | "Set-DesktopWallpaper" 18 | ) 19 | AliasesToExport = @( 20 | "title" 21 | "wtr" 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /Modules/Elevation/Elevation.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2211.2.1' 3 | GUID = 'd4e9a80b-2239-4d7a-a552-b46e17a47863' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Elevation.psm1' 7 | NestedModules = @() 8 | TypesToProcess = @() 9 | FormatsToProcess = @() 10 | FunctionsToExport = @( 11 | "Assert-Elevation" 12 | "Test-Elevation" 13 | "Invoke-ElevatedCommand" 14 | "Invoke-ElevatedCommandAs" 15 | "Invoke-ElevatedScript" 16 | "Invoke-ElevatedExpression" 17 | "Start-ProcessNonElevated" 18 | "Start-RemoteProcess" 19 | ) 20 | AliasesToExport = @( 21 | "sudo" 22 | "runas" 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /Modules/MongoDB/MongoDB.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'MongoDB.psm1' 3 | ModuleVersion = '2020.2.15.1' 4 | GUID = '4f2dd9e5-6623-4293-8c33-0c3c3052f34b' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Export-MongoCollection" 11 | "Find-MongoDBPath" 12 | "Import-MongoCollectionFromCsv" 13 | "Import-MongoCollectionFromDump" 14 | "Invoke-MongoDBClient" 15 | "Start-MongoDBServer" 16 | "Stop-MongoDBServer" 17 | ) 18 | AliasesToExport = @( 19 | "mongodb-client" 20 | "mongodb-start" 21 | "mongodb-stop" 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /Modules/LinuxSubsystem/LinuxSubsystem.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'LinuxSubsystem.psm1' 3 | ModuleVersion = '2301.25.1' 4 | GUID = '64252dac-92cf-41fb-9ef7-94e1a42c56ac' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Disable-LinuxSubsystem" 11 | "Enable-LinuxSubsystem" 12 | "Export-LinuxSubsystemDistribution" 13 | "Get-LinuxSubsystemDistribution" 14 | "Get-LinuxSubsystemParentProcess" 15 | "Import-LinuxSubsystemDistribution" 16 | "Restart-LinuxSubsystem" 17 | "Set-LinuxSubsystemDistribution" 18 | "Test-LinuxSubsystem" 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Test-Docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Test-Docker.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-Docker 9 | 10 | ## SYNOPSIS 11 | 12 | Test if the docker.exe is present. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Test-Docker 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Test-Docker function test to see if docker.exe is present on the system. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Test-Docker 30 | 31 | True 32 | ``` 33 | 34 | This example returns true because docker.exe is installed. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /Modules/DateTime/DateTime.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'DateTime.psm1' 3 | ModuleVersion = '2209.23.1' 4 | GUID = 'a115fad5-9f9c-4aa3-9eb8-03beb9ec4189' 5 | Author = 'Julian Easterling' 6 | Description = '' 7 | FunctionsToExport = @( 8 | "Show-Calendar" 9 | ) 10 | AliasesToExport = @( 11 | "calendar" 12 | ) 13 | PrivateData = @{ 14 | PSData = @{ 15 | Tags = @( 16 | "dcjulian29" 17 | "date" 18 | "time" 19 | "datetime" 20 | ) 21 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 22 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 23 | } 24 | } 25 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/DateTime' 26 | } 27 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Find-Docker.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Find-Docker.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-Docker 9 | 10 | ## SYNOPSIS 11 | 12 | Return the full path to docker.exe. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Find-Docker 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Find-Docker function returns the full path to docker.exe if present. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Find-Docker 30 | C:\Program Files\Docker\Docker\resources\bin\docker.exe 31 | ``` 32 | 33 | This example returns the current location of the docker.exe file. 34 | 35 | ## PARAMETERS 36 | 37 | ### None 38 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Switch-DockerLinuxEngine.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Switch-DockerLinuxEngine.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Switch-DockerLinuxEngine 9 | 10 | ## SYNOPSIS 11 | 12 | Switch to Docker to use Linux containers. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Switch-DockerLinuxEngine 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Switch-DockerLinuxEngine function switches Docker to use Linux containers. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Switch-DockerLinuxEngine 30 | 31 | ``` 32 | 33 | This example switches Docker to use Linux containers. 34 | 35 | ## PARAMETERS 36 | 37 | ### None 38 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Resume-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Resume-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Resume-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Starts existing containers for a service. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Resume-DockerCompose 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Resume-DockerCompose function starts the existing containers. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Resume-DockerCompose 30 | 31 | Starting portainer ... done 32 | ``` 33 | 34 | This example starts the Portainer container after it has been stopped. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Switch-DockerWindowsEngine.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Switch-DockerWindowsEngine.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Switch-DockerWindowsEngine 9 | 10 | ## SYNOPSIS 11 | 12 | Switch to Docker to use Windows containers. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Switch-DockerWindowsEngine 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Switch-DockerWindowsEngine function switches Docker to use Windows containers. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Switch-DockerWindowsEngine 30 | 31 | ``` 32 | 33 | This example switches Docker to use Windows containers. 34 | 35 | ## PARAMETERS 36 | 37 | ### None 38 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Test-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Test-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Test if docker-compose.exe is present. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Test-DockerCompose 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Test-DockerCompose function returns true if docker-compose.exe is present, otherwise false is returned. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Test-DockerCompose 30 | 31 | True 32 | ``` 33 | 34 | This example returns true because docker-compose.exe is present. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /Modules/Node/Node.psm1: -------------------------------------------------------------------------------- 1 | Function Get-Node { 2 | Find-ProgramFiles 'nodejs\node.exe' 3 | } 4 | 5 | Function Get-Npm { 6 | if (Test-Node) { 7 | "$(Split-Path $script:node)\node_modules\npm\bin\npm-cli.js" 8 | } 9 | } 10 | 11 | Function Get-NodeVersion { 12 | Start-Node -p -e "process.versions.node + ' (' + process.arch + ')'" 13 | } 14 | 15 | Function Start-NodePackageManager { 16 | Start-Node Get-Npm $args; 17 | } 18 | 19 | Function Start-Node { 20 | if (Test-Node) { 21 | & Get-Node $args 22 | } else { 23 | Write-Error "NodeJS is not installed!" 24 | } 25 | } 26 | 27 | Function Test-Node { 28 | Test-Path Get-Node 29 | } 30 | 31 | ############################################################################### 32 | 33 | Set-Alias npm Start-NodePackageManager 34 | Set-Alias node Start-Node 35 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Test-DockerLinuxEngine.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Test-DockerLinuxEngine.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-DockerLinuxEngine 9 | 10 | ## SYNOPSIS 11 | 12 | Test if Docker is using Linux containers. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Test-DockerLinuxEngine 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Test-DockerLinuxEngine function tests to see if Docker is using Linux containers. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Test-DockerLinuxEngine 30 | 31 | True 32 | ``` 33 | 34 | This example returns true because Docker is currently using Linux containers. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Suspend-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Suspend-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Suspend-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Stops running containers without removing them. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Suspend-DockerCompose 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Suspend-DockerCompose function stops running containers but does not remove them. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Suspend-DockerCompose 30 | 31 | Stopping portainer_portainer_1 ... done 32 | ``` 33 | 34 | This example stops the running Portainer container. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /choco/dcjulian29.psmodules/mine.json: -------------------------------------------------------------------------------- 1 | [ 2 | "AzureDevOps", 3 | "Chocolatey", 4 | "Code", 5 | "DateTime", 6 | "DotNet", 7 | "Drive", 8 | "Editors", 9 | "ElasticSearch", 10 | "Elevation", 11 | "FileSystem", 12 | "Kubernetes", 13 | "LinuxSubsystem", 14 | "Logging", 15 | "LogStash", 16 | "MongoDB", 17 | "Networking", 18 | "Node", 19 | "NuGet", 20 | "OctopusDeploy", 21 | "OpenSSH", 22 | "OperatingSystem", 23 | "PowershellForAnsible", 24 | "PowershellForDocker", 25 | "PowershellForGit", 26 | "PowershellForOpenSSL", 27 | "PowershellForVirtualBox", 28 | "PSExtensions", 29 | "PSModules", 30 | "RemoteRDP", 31 | "SqlServer", 32 | "TeamCity", 33 | "TextFormatting", 34 | "UI", 35 | "Versioning", 36 | "VirtualBaseDisk", 37 | "VirtualDevelopment", 38 | "VirtualLab", 39 | "VirtualMachines", 40 | "VisualStudio", 41 | "WebCredential" 42 | ] 43 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Find-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Find-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Return the full path to docker-compose.exe. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Find-DockerCompose 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Find-DockerCompose function returns the full path to docker-composed.exe if present. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Find-DockerCompose 30 | C:\ProgramData\chocolatey\bin\docker-compose.exe 31 | ``` 32 | 33 | This example returns the current location of the docker-compose.exe file. 34 | 35 | ## PARAMETERS 36 | 37 | ### None 38 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerServerEngine.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerServerEngine.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerServerEngine 9 | 10 | ## SYNOPSIS 11 | 12 | Get which kernel the Docker engine is using. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-DockerServerEngine 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-DockerServerEngine function shows which kernel the Docker engine is currently using. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-DockerServerEngine 30 | 31 | linux/amd64 32 | ``` 33 | 34 | This example shows that the Docker engine is currently set to Linux containers. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Invoke-DebianContainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Invoke-DebianContainer.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-DebianContainer 9 | 10 | ## SYNOPSIS 11 | 12 | Start and Debian constainer ane enter the ASH shell. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Invoke-DebianContainer 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Invoke-DebianContainer function starts an Debian Linux container and starts the default bash shell. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Invoke-DebianContainer 30 | root@adeaa417bc32:/# 31 | ``` 32 | 33 | This example starts an Debian Linux container and bash shell. 34 | 35 | ## PARAMETERS 36 | 37 | ### None 38 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Test-DockerWindowsEngine.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Test-DockerWindowsEngine.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-DockerWindowsEngine 9 | 10 | ## SYNOPSIS 11 | 12 | Test if Docker is using Windows containers. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Test-DockerWindowsEngine 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Test-DockerWindowsEngine function tests to see if Docker is using Windows containers. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Test-DockerWindowsEngine 30 | 31 | False 32 | ``` 33 | 34 | This example returns false because Docker is not currently using Windows containers. 35 | 36 | ## PARAMETERS 37 | 38 | ### None 39 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitConfig.psm1: -------------------------------------------------------------------------------- 1 | function Get-GitConfigValue { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory=$true, Position=0)] 5 | [string] $Key 6 | ) 7 | 8 | $parameters = "config --get $Key" 9 | 10 | cmd /c """$(Find-Git)"" $parameters" 11 | } 12 | 13 | function Set-GitConfigValue { 14 | [CmdletBinding()] 15 | param ( 16 | [Parameter(Mandatory=$true, Position=0)] 17 | [string] $key, 18 | [Parameter(Mandatory=$false, Position=1)] 19 | [string] $value, 20 | [ValidateSet("global", "local", "system")] 21 | [string] $Scope = "local" 22 | ) 23 | 24 | $parameters = "config" 25 | 26 | if ([System.String]::IsNullOrEmpty($Value)) { 27 | $parameters += " --unset $Key" 28 | } else { 29 | $parameters += " --$Scope $Key '$Value'" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Modules/PowershellForVirtualBox/PowershellForVirtualBox.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = "VirtualBox.psm1" 3 | ModuleVersion = "2110.12.4" 4 | GUID = "c66d09da-ef6d-411b-8708-9526b68533fa" 5 | Author = "Julian Easterling" 6 | PowerShellVersion = "3.0" 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | NestedModules = @() 10 | FunctionsToExport = @( 11 | "Get-VirtualBoxMachine" 12 | "Get-VirtualBoxProcess" 13 | "Find-VirtualBox" 14 | "Invoke-VirtualBox" 15 | "Save-VirtualBoxMachine" 16 | "Start-VirtualBoxMachine" 17 | "Stop-VirtualBoxMachine" 18 | ) 19 | AliasesToExport = @( 20 | "Get-VBoxMachine" 21 | "gvbm" 22 | "Resume-VirtualBoxMachine" 23 | "Resume-VBoxMachine" 24 | "Start-VBoxMachine" 25 | "Stop-VBoxMachine" 26 | "vbox" 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /choco/dcjulian29.psmodules/chocolateyPackage.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dcjulian29.psmodules 5 | $version$ 6 | Julian Easterling 7 | Julian Easterling 8 | https://raw.githubusercontent.com/dcjulian29/scripts-powershell/main/LICENSE.md 9 | https://github.com/dcjulian29/scripts-powershell 10 | My Powershell modules 11 | dcjulian29 pshell pwsh powershell modules 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Modules/Kubernetes/Kubernetes.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2106.3.1' 3 | GUID = 'f5af3a59-c5ad-4e26-8502-c14c3ee8d5df' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Kubernetes.psm1' 7 | NestedModules = @( 8 | "k3s.psm1" 9 | ) 10 | TypesToProcess = @() 11 | FormatsToProcess = @() 12 | FunctionsToExport = @( 13 | "Find-KubeControl" 14 | "Get-K3SCluster" 15 | "Install-K3D" 16 | "Invoke-KubeControl" 17 | "New-K3S" 18 | "Open-K3SDashboard" 19 | "Remove-K3S" 20 | "Start-K3S" 21 | "Start-K3SDashboard" 22 | "Stop-K3S" 23 | "Test-K3D" 24 | "Use-K3S" 25 | "Use-K8SContext" 26 | ) 27 | AliasesToExport = @( 28 | "Find-KubeCTL" 29 | "Invoke-KubeCTL" 30 | "k" 31 | "k3s-start" 32 | "k3s-stop" 33 | "k3s-remove" 34 | "kubectl" 35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /Modules/RemoteRDP/RemoteRDP.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'RemoteRDP.psm1' 3 | ModuleVersion = '2105.24.1' 4 | GUID = '9476a49d-58bf-414f-89d8-619bf4f552b7' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Get-ActiveRdpSession" 11 | "Get-DisconnectedRdpSession" 12 | "Get-RdpSession" 13 | "Close-RdpSession" 14 | "Disable-RdpHostFile" 15 | "Disable-RdpHostFileDirectory" 16 | "Find-RdpHost" 17 | "Find-RdpHostFile" 18 | "Find-RdpHostFileDirectory" 19 | "New-RemoteDesktopShortcut" 20 | "Restore-RdpHostFile" 21 | "Restore-RdpHostFileDirectory" 22 | ) 23 | AliasesToExport = @( 24 | "rdplist" 25 | "rdpkick" 26 | "New-RdpShortcut" 27 | "Validate-RdpHost" 28 | "Validate-RdpHostFile" 29 | "Validate-RdpHostFileDirectory" 30 | ) 31 | } 32 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Invoke-Dive.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Invoke-Dive.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-Dive 9 | 10 | ## SYNOPSIS 11 | 12 | Invoke a tool for exploring a docker image 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Invoke-Dive 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Invoke-Dive function is a wrapper around a tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker/OCI image. Additionally the tool estimates the amount of wasted space and identifies the offending files from the image. 23 | 24 | > **_NOTE:_** Anything after the function name is passed unmodified as arguments. 25 | 26 | ## EXAMPLES 27 | 28 | ### Example 1 29 | 30 | ```powershell 31 | PS C:\> Invoke-Dive 32 | No image argument given 33 | ``` 34 | 35 | This example invokes the Dive tool. 36 | -------------------------------------------------------------------------------- /Modules/Chocolatey/Chocolatey.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'Chocolatey.psm1' 3 | ModuleVersion = '2205.8.1' 4 | GUID = '36e1692e-e76a-421e-a04e-e4c0460e12fe' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Find-InstalledChocolateyPackages" 11 | "Find-UpgradableChocolateyPackages" 12 | "Install-ChocolateyPackage" 13 | "Invoke-ChocolateyInstall" 14 | "Invoke-ChocolateyShell" 15 | "New-ChocolateyPackage" 16 | "Optimize-ChocolateyCache" 17 | "Restore-ChocolateyCache" 18 | "Update-AllChocolateyPackages" 19 | "Update-ChocolateyPackage" 20 | "Uninstall-ChocolateyPackage" 21 | ) 22 | AliasesToExport = @( 23 | "chocoupdate" 24 | "choco-make-package" 25 | "Make-ChocolateyPackage" 26 | "Upgrade-AllChocolateyPackage" 27 | "Upgrade-ChocolateyPackage" 28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /Modules/LogStash/LogStash.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2106.6.1' 3 | GUID = '2d6efd08-0859-4734-a2e0-c873bd36ccb4' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'LogStash.psm1' 7 | NestedModules = @() 8 | TypesToProcess = @() 9 | FormatsToProcess = @() 10 | FunctionsToExport = @( 11 | "Clear-LogStashProfile" 12 | "Get-LogStashHotThreads" 13 | "Get-LogStashNode" 14 | "Get-LogStashPipeline" 15 | "Get-LogStashPlugins" 16 | "Get-LogStashServer" 17 | "Import-LogStashProfile" 18 | "Invoke-LogStashApi" 19 | "New-LogStashProfile" 20 | "Set-LogStashProfile" 21 | "Test-LogStashProfile" 22 | "Use-LogStashProfile" 23 | ) 24 | AliasesToExport = @( 25 | "Load-LogStashProfile" 26 | "ls-api" 27 | "logstash-api" 28 | "logstash-profile-clear" 29 | "ls-profile-clear" 30 | "logstash-profile-load" 31 | "ls-profile-load" 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /Modules/VirtualMachines/VirtualMachines.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2412.7.1' 3 | GUID = 'e6dcee49-99f8-4788-b4ca-786ec17b7aba' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'VirtualMachines.psm1' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Compress-Vhdx" 11 | "Connect-IsoToVirtual" 12 | "Get-VirtualizationManagementService" 13 | "Get-VirtualizationNamespace" 14 | "Get-VirtualMachineStatus" 15 | "Mount-Vhdx" 16 | "Move-FileToVM" 17 | "Move-FilesToVM" 18 | "Move-StartLayoutToVM" 19 | "Move-VMStartUpScriptBlockToVM" 20 | "Move-VMStartUpScriptFileToVM" 21 | "New-DataVhdx" 22 | "New-DifferencingVhdx" 23 | "New-SystemVhdx" 24 | "New-UnattendFile" 25 | "New-VirtualMachine" 26 | "Select-VirtualMachine" 27 | "Uninstall-VirtualMachine" 28 | ) 29 | AliasesToExport = @( 30 | "New-ReferenceVhdx" 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /Modules/DotNet/DotNet.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2020.6.4.1' 3 | GUID = 'da9c1ff2-0ed8-4d45-85d5-0261bc079894' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'DotNet.psm1' 7 | NestedModules = @() 8 | TypesToProcess = @() 9 | FormatsToProcess = @() 10 | FunctionsToExport = @( 11 | "Get-AllAssemblyInfo" 12 | "Get-AssemblyInfo" 13 | "Get-NetFramework" 14 | "Get-RemoteNetFramework" 15 | "Test-NetFramework" 16 | "Test-NetFramework2" 17 | "Test-NetFramework3" 18 | "Test-NetFramework35" 19 | "Test-NetFramework40" 20 | "Test-NetFramework45" 21 | "Test-NetFramework451" 22 | "Test-NetFramework452" 23 | "Test-NetFramework46" 24 | "Test-NetFramework461" 25 | "Test-NetFramework462" 26 | "Test-NetFramework47" 27 | "Test-NetFramework471" 28 | "Test-NetFramework472" 29 | "Test-NetFramework48" 30 | ) 31 | AliasesToExport = @( 32 | "aia" 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /Modules/UI/Pin-Taskbar.ps1: -------------------------------------------------------------------------------- 1 | Function Pin-Taskbar { 2 | param ( 3 | [Parameter(Mandatory=$true)] 4 | [ValidateNotNullOrEmpty()] 5 | [ValidateScript({ Test-Path $(Resolve-Path $_) })] 6 | [string]$Item, 7 | 8 | [ValidateSet("Pin","Unpin")] 9 | [Parameter(Mandatory=$true)] 10 | [ValidateNotNullOrEmpty()] 11 | [string]$Action 12 | ) 13 | 14 | $Item = Resolve-Path $Item 15 | $ItemParent = Split-Path -Path $Item -Parent 16 | $ItemLeaf = Split-Path -Path $Item -Leaf 17 | 18 | $Shell = New-Object -ComObject "Shell.Application" 19 | $Folder = $Shell.NameSpace($ItemParent) 20 | $ItemObject = $Folder.ParseName($ItemLeaf) 21 | $Verbs = $ItemObject.Verbs() 22 | 23 | switch($Action) { 24 | "Pin" { 25 | $Verb = $Verbs | Where-Object -Property Name -EQ "Pin to Tas&kbar" 26 | } 27 | 28 | "Unpin" { 29 | $Verb = $Verbs | Where-Object -Property Name -EQ "Unpin from Tas&kbar" 30 | } 31 | } 32 | 33 | $Result = $Verb.DoIt() 34 | } 35 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/AnsibleVault.psm1: -------------------------------------------------------------------------------- 1 | function Edit-AnsibleVault { 2 | [CmdletBinding()] 3 | [Alias("ansible-vault-edit")] 4 | param ( 5 | [ValidateScript({ Test-Path $(Resolve-Path $_) })] 6 | [string] $Vault 7 | ) 8 | 9 | if ($Vault.Length -eq 0) { 10 | $Vault = "./secrets.yml" 11 | } 12 | 13 | ansible-vault edit $Vault 14 | } 15 | 16 | function Protect-AnsibleVariable { 17 | [Alias("ansible-encrypt")] 18 | param( 19 | [Parameter(Mandatory=$true)] 20 | [ValidateNotNullOrEmpty()] 21 | [string] $Value, 22 | [Parameter(Mandatory=$true)] 23 | [ValidateNotNullOrEmpty()] 24 | [string] $VariableName 25 | ) 26 | 27 | ansible-vault encrypt_string `"$Value`" --name $VariableName 28 | } 29 | 30 | function Show-AnsibleVault { 31 | [CmdletBinding()] 32 | [Alias("ansible-vault-view")] 33 | param ( 34 | [ValidateScript({ Test-Path $(Resolve-Path $_) })] 35 | [string] $Vault 36 | ) 37 | 38 | if ($Vault.Length -eq 0) { 39 | $Vault = "./secrets.yml" 40 | } 41 | 42 | ansible-vault view $Vault 43 | } 44 | -------------------------------------------------------------------------------- /Modules/Versioning/Versioning.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2201.9.2' 3 | GUID = 'c3dae059-3060-43cf-8492-45eb86b78cf6' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Versioning.psm1' 7 | NestedModules = @( 8 | "VersioningSemantic.psm1" 9 | ) 10 | TypesToProcess = @() 11 | FormatsToProcess = @() 12 | FunctionsToExport = @( 13 | "ConvertFrom-DatedVersion" 14 | "ConvertTo-AssemblyVersion" 15 | "Get-SemanticVersion" 16 | "Get-Version" 17 | "New-SemanticVersion" 18 | "New-Version" 19 | "Set-SemanticVersion" 20 | "Set-Version" 21 | "Step-BuildVersion" 22 | "Step-MajorVersion" 23 | "Step-MinorVersion" 24 | "Step-RevisionVersion" 25 | "Step-SemanticMajorVersion" 26 | "Step-SemanticMinorVersion" 27 | "Step-SemanticPatchVersion" 28 | "Test-SemanticVersion" 29 | "Test-Version" 30 | ) 31 | AliasesToExport = @( 32 | "Get-SemVer" 33 | "New-SemVer" 34 | "Test-SemVer" 35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /Modules/PSExtensions/README.md: -------------------------------------------------------------------------------- 1 | # PSExtensions ![Version](https://img.shields.io/myget/dcjulian29-powershell/v/PSExtensions) 2 | 3 | A collection of utilities, commands, and functions specific to extending Powershell. 4 | 5 | ## Functions 6 | 7 | ### [Edit-Profile](docs/Edit-Profile.md) 8 | 9 | ### [Get-AvailableExceptionsList](docs/Get-AvailableExceptionsList.md) 10 | 11 | ### [Get-LastExecutionTime](docs/Get-LastExecutionTime.md) 12 | 13 | ### [Get-PowershellVerbs](docs/Get-PowershellVerbs.md) 14 | 15 | ### [Get-Profile](docs/Get-Profile.md) 16 | 17 | ### [Import-Assembly](docs/Import-Assembly.md) 18 | 19 | ### [New-ErrorRecord](docs/New-ErrorRecord.md) 20 | 21 | ### [Remove-AliasesFromScript](docs/Remove-AliasesFromScript.md) 22 | 23 | ### [Search-Command](docs/Search-Command.md) 24 | 25 | ### [Test-IsNonInteractive](docs/Test-IsNonInteractive.md) 26 | 27 | ### [Test-PowershellVerb](docs/Test-PowershellVerb.md) 28 | 29 | ### [Update-MyProfile](docs/Update-MyProfile.md) 30 | 31 | ### [Update-Profile](docs/Update-Profile.md) 32 | 33 | ## Aliases 34 | 35 | ### [Load-Assembly](docs/Import-Assembly.md) 36 | 37 | ### [Find-PSCommand](docs/Search-Command.md) 38 | -------------------------------------------------------------------------------- /Modules/VirtualLab/VirtualLab.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2412.7.1' 3 | GUID = 'fa07d906-a7c4-4a32-a845-6b54a7cb04d6' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'VirtualLab.psm1' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "New-LabDebianServer" 11 | "New-LabDomainController" 12 | "New-LabFirewall" 13 | "New-LabMintWorkstation" 14 | "New-LabRockyServer" 15 | "New-LabUbuntuServer" 16 | "New-LabUbuntuMateWorkstation" 17 | "New-LabUbuntuWorkstation" 18 | "New-LabVMFromISO" 19 | "New-LabVMSwitch" 20 | "New-LabWindowsServer" 21 | "New-LabWindowsWorkstation" 22 | "Start-LabDomainController" 23 | "Start-LabFirewall" 24 | "Stop-LabDomainController" 25 | "Stop-LabFirewall" 26 | "Remove-LabDomainController" 27 | "Remove-LabFirewall" 28 | "Remove-LabVMSwitch" 29 | ) 30 | AliasesToExport = @( 31 | "New-LabLinuxServer" 32 | "New-LabLinuxWorkstation" 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /Modules/Networking/IPerf.psm1: -------------------------------------------------------------------------------- 1 | function Find-Iperf { 2 | First-Path ` 3 | ("${env:SystemDrive}\tools\iperf\iperf3.exe") 4 | } 5 | 6 | function Invoke-IPerf { 7 | if (-not (Test-Path $(Find-IPerf))) { 8 | Write-Output "iPerf is not installed on this system." 9 | } else { 10 | $param = "$args" 11 | 12 | $ea = $ErrorActionPreference 13 | $ErrorActionPreference = "SilentlyContinue" 14 | 15 | Start-Process -FilePath $(Find-Iperf) -ArgumentList $param -Wait -NoNewWindow 16 | 17 | $ErrorActionPreference = $ea 18 | } 19 | } 20 | 21 | Set-Alias iperf Invoke-IPerf 22 | 23 | function Invoke-IPerfClient { 24 | param ( 25 | [Parameter(Mandatory=$true)] 26 | [ValidateNotNullOrEmpty()] 27 | [string]$IperfServer, 28 | [int]$Seconds = "30" 29 | ) 30 | 31 | Invoke-IPerf -c $IperfServer -i 1 -t $Seconds 32 | } 33 | 34 | Set-Alias iperf-client Invoke-IPerfClient 35 | 36 | function Invoke-IPerfServer { 37 | Write-Output "Press Ctrl-C to stop IPerf Server." 38 | Invoke-IPerf -s -i 1 39 | } 40 | 41 | Set-Alias iperf-server Invoke-IPerfServer 42 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Edit-Profile.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Edit-Profile.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Edit-Profile1 9 | 10 | ## SYNOPSIS 11 | 12 | Open the current profile script in Notepad. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Edit-Profile [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Edit-Profile cmdlet opens the current profile script in Notepad. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Edit-Profile 30 | ``` 31 | 32 | This example opens the current profile script in Notepad. 33 | 34 | ## PARAMETERS 35 | 36 | ### CommonParameters 37 | 38 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 39 | 40 | ## INPUTS 41 | 42 | ## OUTPUTS 43 | 44 | ## NOTES 45 | 46 | ## RELATED LINKS 47 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Update-Profile.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Update-Profile.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Update-Profile 9 | 10 | ## SYNOPSIS 11 | 12 | Reload the profile script. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Update-Profile [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Update-Profile cmdlet reloads the profile script into the current session. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Update-Profile 30 | ``` 31 | 32 | This example reloads the profile script in the current session. 33 | 34 | ## PARAMETERS 35 | 36 | ### CommonParameters 37 | 38 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 39 | 40 | ## INPUTS 41 | 42 | ## OUTPUTS 43 | 44 | ## NOTES 45 | 46 | ## RELATED LINKS 47 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitFlowHotFix.psm1: -------------------------------------------------------------------------------- 1 | function Pop-GitFlowHotfix { 2 | param ( 3 | [string] $Name = "$(Read-Host 'What is the name of the hotfix')" 4 | ) 5 | 6 | & "$(Find-Git)" flow hotfix pull $Name 7 | } 8 | 9 | Set-Alias Pull-GitFlowHotfix Pop-GitFlowHotfix 10 | 11 | function Publish-GitFlowHotfix { 12 | param ( 13 | [string] $Name = "$(Read-Host 'What is the name of the hotfix')" 14 | ) 15 | 16 | & "$(Find-Git)" flow hotfix publish $Name 17 | } 18 | 19 | function Remove-GitFlowHotfix { 20 | & "$(Find-Git)" fetch 21 | & "$(Find-Git)" flow hotfix delete --remote 22 | & "$(Find-Git)" checkout develop 23 | & "$(Find-Git)" pull 24 | } 25 | 26 | Set-Alias Abort-GitFlowHotfix Remove-GitFlowHotfix 27 | 28 | function Start-GitFlowHotfix { 29 | param ( 30 | [string] $Name = "$(Read-Host 'What is the name of the hotfix')" 31 | ) 32 | 33 | & "$(Find-Git)" flow hotfix start $Name 34 | } 35 | 36 | Set-Alias gfhs Start-GitFlowHotfix 37 | 38 | function Stop-GitFlowHotfix { 39 | & "$(Find-Git)" flow hotfix finish -m "Hotfix" 40 | } 41 | 42 | Set-Alias gfhf Stop-GitFlowHotfix 43 | Set-Alias Finish-GitFlowHotfix Stop-GitFlowHotfix 44 | -------------------------------------------------------------------------------- /Modules/NuGet/NuGet.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2102.18.1' 3 | GUID = 'b3764581-214b-4403-b277-e97b6ad00c51' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'NuGet.psm1' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Clear-NuGetProfile" 11 | "Find-NuGet" 12 | "Get-NuGetMetaData" 13 | "Get-NuGetPackage" 14 | "Get-NuSpecMetaData" 15 | "Import-NuGetProfile" 16 | "Invoke-NuGet" 17 | "New-NuGetPackage" 18 | "Push-NuGetPackage" 19 | "Remove-AllNuGetPackages" 20 | "Remove-AllNuGetPackagesFromCache" 21 | "Remove-NuGetPackagesFromCache" 22 | "Restore-NuGetPackages" 23 | ) 24 | AliasesToExport = @( 25 | "Create-NuGetPackage" 26 | "Load-NuGetProfile" 27 | "nuget-metadata" 28 | "nuget-profile-clear" 29 | "nuget-profile-load" 30 | "nuget-package-clean" 31 | "nuget-make-package" 32 | "nuget-publish" 33 | "Purge-AllNuGetPackages" 34 | "Purge-AllNuGetPackagesFromCache" 35 | "Purge-NuGetPackagesFromCache" 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /Modules/Kubernetes/kubescape.psm1: -------------------------------------------------------------------------------- 1 | $script:BASE_DIR= "${env:USERPROFILE}/.kubescape" 2 | 3 | function getKubescapeConfig { 4 | Invoke-WebRequest "https://api.github.com/repos/armosec/kubescape/releases/latest" | ConvertFrom-Json 5 | } 6 | 7 | function getKubescapeRelease { 8 | return $(getKubescape).tag_name 9 | } 10 | 11 | function getKubescapeReleaseUrl { 12 | return $(getKubescape).html_url.Replace("/tag/","/download/") + "/kubescape-windows-latest" 13 | } 14 | 15 | ############################################################################## 16 | 17 | function Install-Kubescape { 18 | if (Test-Kubescape) { 19 | Write-Warning "Kubescape is already installed." 20 | } else { 21 | Invoke-WebRequest -Uri "$(getKubescapeReleaseUrl)" -OutFile "${script:BASE_DIR}/kubescape.exe" 22 | } 23 | } 24 | 25 | function Invoke-Kubescape { 26 | & "${script:BASE_DIR}/kubescape.exe" $args 27 | } 28 | 29 | Set-Alias -Name kubescape -Value Invoke-Kubescape 30 | 31 | function Scan-Kubescape { 32 | & "${script:BASE_DIR}/kubescape.exe" scan framework nsa ./* 33 | } 34 | 35 | function Test-Kubescape { 36 | return $(Test-Path "${script:BASE_DIR}/kubescape.exe") 37 | } 38 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitFlowRelease.psm1: -------------------------------------------------------------------------------- 1 | function Pop-GitFlowRelease { 2 | param ( 3 | [string] $Name = "$(Read-Host 'What is the name of the release')" 4 | ) 5 | 6 | & "$(Find-Git)" flow release pull $Name 7 | } 8 | 9 | Set-Alias Pull-GitFlowRelease Pop-GitFlowRelease 10 | 11 | function Publish-GitFlowRelease { 12 | param ( 13 | [string] $Name = "$(Read-Host 'What is the name of the release')" 14 | ) 15 | 16 | & "$(Find-Git)" flow release publish $Name 17 | } 18 | 19 | function Remove-GitFlowRelease { 20 | & "$(Find-Git)" fetch 21 | & "$(Find-Git)" flow release delete --remote 22 | & "$(Find-Git)" checkout develop 23 | & "$(Find-Git)" pull 24 | } 25 | 26 | Set-Alias Abort-GitFlowRelease Remove-GitFlowRelease 27 | 28 | function Start-GitFlowRelease { 29 | param ( 30 | [string] $Name = "$(Read-Host 'What is the name of the release')" 31 | ) 32 | 33 | & "$(Find-Git)" flow release start $Name 34 | } 35 | 36 | Set-Alias gfrs Start-GitFlowRelease 37 | 38 | function Stop-GitFlowRelease { 39 | & "$(Find-Git)" flow release finish -m "Release" 40 | } 41 | 42 | Set-Alias gfrf Stop-GitFlowRelease 43 | Set-Alias Finish-GitFlowRelease Stop-GitFlowRelease 44 | -------------------------------------------------------------------------------- /Modules/Kubernetes/Kubernetes.psm1: -------------------------------------------------------------------------------- 1 | function Find-KubeControl { 2 | First-Path ` 3 | "${env:ALLUSERSPROFILE}\chocolatey\lib\kubernetes-cli\tools\kubernetes\client\bin\kubectl.exe" ` 4 | (Find-ProgramFiles "Docker\Docker\Resources\bin\kubectl.exe") 5 | } 6 | 7 | Set-Alias -Name Find-KubeCTL -Value Find-KubeControl 8 | 9 | function Invoke-KubeControl { 10 | $kubectl = Find-KubeControl 11 | 12 | if ($kubectl) { 13 | if (Test-KubeControl) { 14 | cmd /c """$kubectl"" $args" 15 | } else { 16 | throw "Kubernetes Control is not installed on this system." 17 | } 18 | } 19 | } 20 | 21 | Set-Alias -Name Invoke-KubeControl -Value Invoke-KubeControl 22 | Set-Alias -Name k -Value Invoke-KubeControl 23 | 24 | function Test-KubeControl { 25 | $kubectl = Find-KubeControl 26 | 27 | if ($kubectl) { 28 | if (Test-Path $kubectl) { 29 | return $true 30 | } else { 31 | return $false 32 | } 33 | } 34 | } 35 | 36 | function Use-K8SContext { 37 | param ( 38 | [Parameter(Mandatory = $true)] 39 | [string] $Context 40 | ) 41 | 42 | kubectl config use-context "$Context" 43 | } 44 | -------------------------------------------------------------------------------- /Modules/VisualStudio/VisualStudio.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'VisualStudio.psm1' 3 | ModuleVersion = '2211.16.1' 4 | GUID = '1f375f95-3e56-426c-831b-3ff97ed8f0a2' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Find-VisualStudio" 11 | "Find-VisualStudioSolutions" 12 | "Find-VSIX" 13 | "Find-VSVars" 14 | "Get-VsixUrl" 15 | "Get-VSVars" 16 | "Import-VSVars" 17 | "Install-VsixByName" 18 | "Install-VsixPackage" 19 | "Show-VisualStudioInstalledVersions" 20 | "Show-VsixExtensions" 21 | "Start-VisualStudio" 22 | "Start-VisualStudio2019" 23 | "Start-VisualStudio2022" 24 | "Start-VisualStudioCode" 25 | "Test-VisualStudioInstalledVersion" 26 | ) 27 | AliasesToExport = @( 28 | "code" 29 | "Find-VisualStudioVariables" 30 | "Register-VisualStudioVariables" 31 | "Register-VSVariables" 32 | "vs-solutions" 33 | "vs2019" 34 | "vs2022" 35 | "vscode" 36 | "vsvars32" 37 | "VSVariables" 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Get-Profile.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Get-Profile.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-Profile 9 | 10 | ## SYNOPSIS 11 | 12 | Get the contents of the currently loaded profile script. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-Profile [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-Profile cmdlet returns the contents of the currently loaded profile script. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-Profile 30 | 31 | function prompt { 32 | ... 33 | } 34 | ``` 35 | 36 | This example shows the contents of the currently loaded profile script. 37 | 38 | ## PARAMETERS 39 | 40 | ### CommonParameters 41 | 42 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 43 | 44 | ## INPUTS 45 | 46 | ## OUTPUTS 47 | 48 | ## NOTES 49 | 50 | ## RELATED LINKS 51 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerDiskUsage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerDiskUsage.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerDiskUsage 9 | 10 | ## SYNOPSIS 11 | 12 | Get the amount of disk space Docker is consuming. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-DockerDiskUsage 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-DockerDiskUsage function returns the amount of disk space used by Docker images, containers local volumes, and the build cache. It also includes the reclaimable space as well. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-DockerDiskUsage | Format-Table 30 | 31 | 32 | Type Total Active Size Reclaimable 33 | ---- ----- ------ ---- ----------- 34 | Images 19 0 9718437249 9718437249 35 | Containers 0 0 0 0 36 | Local Volumes 0 0 0 0 37 | Build Cache 139 0 20884278477 20884278477 38 | ``` 39 | 40 | This example shows the current disk used by Docker. 41 | 42 | ## PARAMETERS 43 | 44 | ### None 45 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Update-MyProfile.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Update-MyProfile.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Update-MyProfile 9 | 10 | ## SYNOPSIS 11 | 12 | Download and update my profile scripts. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Update-MyProfile [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Update-MyProfile cmdlet downloads and replaces my profile scripts in my user profile directory. It then reloads the profile script for the current host. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Update-MyProfile 30 | ``` 31 | 32 | This example downloads and replaces my profile scripts. 33 | 34 | ## PARAMETERS 35 | 36 | ### CommonParameters 37 | 38 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 39 | 40 | ## INPUTS 41 | 42 | ## OUTPUTS 43 | 44 | ## NOTES 45 | 46 | ## RELATED LINKS 47 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/AnsibleInventory.psm1: -------------------------------------------------------------------------------- 1 | function executeInventory([string]$Action, [string]$InventoryFile) { 2 | $Action = $action.Trim() 3 | 4 | if ("" -ne $InventoryFile) { 5 | $InventoryFile = Get-FileNameForContainer $InventoryFile 6 | 7 | ansible-inventory "--inventory $InventoryFile $Action" 8 | } else { 9 | ansible-inventory "$Action" 10 | } 11 | } 12 | 13 | #------------------------------------------------------------------------------ 14 | 15 | function Get-AnsibleInventoryGraph { 16 | [CmdletBinding()] 17 | param ( 18 | [string] $InventoryFile 19 | ) 20 | 21 | executeInventory '--graph' $InventoryFile 22 | } 23 | 24 | function Get-AnsibleInventoryAsJson { 25 | [CmdletBinding()] 26 | param ( 27 | [string] $InventoryFile 28 | ) 29 | 30 | executeInventory '--list' $InventoryFile 31 | } 32 | 33 | function Get-AnsibleInventoryAsToml { 34 | [CmdletBinding()] 35 | param ( 36 | [string] $InventoryFile 37 | ) 38 | 39 | executeInventory '--list --toml' $InventoryFile 40 | } 41 | 42 | function Get-AnsibleInventoryAsYaml { 43 | [CmdletBinding()] 44 | param ( 45 | [string] $InventoryFile 46 | ) 47 | 48 | executeInventory '--list --yaml' $InventoryFile 49 | } 50 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Stop-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Stop-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Stop-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Stops containers and removes containers, networks, volumes, and images. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Stop-DockerCompose 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Stop-DockerCompose function stops running containers, then removes any configured networks, volumes, and potentially images. 23 | 24 | By default, the only things removed are: 25 | 26 | - Containers for services defined in the Compose file 27 | - Networks defined in the networks section of the Compose file 28 | - The default network, if one is used 29 | 30 | Networks and volumes defined as `external` are never removed. 31 | 32 | ## EXAMPLES 33 | 34 | ### Example 1 35 | 36 | ```powershell 37 | PS C:\> Stop-DockerCompose 38 | 39 | Removing portainer_portainer_1 ... done 40 | Removing network portainer_default 41 | ``` 42 | 43 | This example stops and removes the Portainer container and removes the default network that was created. 44 | 45 | ## PARAMETERS 46 | 47 | ### None 48 | -------------------------------------------------------------------------------- /Modules/WebCredential/WebCredential.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'WebCredential.psm1' 3 | ModuleVersion = '2201.17.1' 4 | Description = "A collection of commands to interact with the Windows Credential Manager." 5 | GUID = 'e2f61e99-799f-4f18-9a1e-d217dceea068' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @() 10 | RequiredAssemblies = @() 11 | ScriptsToProcess = @() 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | NestedModules = @() 15 | FunctionsToExport = @( 16 | "Get-WebCredential" 17 | "Remove-WebCredential" 18 | "Set-WebCredential" 19 | ) 20 | CmdletsToExport = @() 21 | VariablesToExport = @() 22 | AliasesToExport = @() 23 | PrivateData = @{ 24 | PSData = @{ 25 | Tags = @( 26 | "dcjulian29" 27 | "Credentials" 28 | "Web" 29 | ) 30 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 31 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 32 | RequireLicenseAcceptance = $false 33 | ExternalModuleDependencies = @() 34 | } 35 | } 36 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/WebCredential' 37 | } 38 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Test-IsNonInteractive.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Test-IsNonInteractive.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-IsNonInteractive 9 | 10 | ## SYNOPSIS 11 | 12 | Test if the current Powershell session is non-interactive. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Test-IsNonInteractive [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Test-IsNonInteractive cmdlet will test if the powershell session is non-interactive or launched as a interactive process. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Test-IsNonInteractive 30 | False 31 | ``` 32 | 33 | This example returns false when executed from a Powershell console host. 34 | 35 | ## PARAMETERS 36 | 37 | ### CommonParameters 38 | 39 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 40 | 41 | ## INPUTS 42 | 43 | ## OUTPUTS 44 | 45 | ## NOTES 46 | 47 | ## RELATED LINKS 48 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-RunningDockerContainers.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-RunningDockerContainers.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-RunningDockerContainers 9 | 10 | ## SYNOPSIS 11 | 12 | Get the running containers. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-RunningDockerContainers 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-RunningDockerContainers function returns the currently running containers. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-RunningDockerContainers 30 | 31 | 32 | Id : d13a1b3408c9b399e20788ed211be9858597e86bed78ed81b3c898b217fa8cdc 33 | Image : alpine:latest 34 | Command : "/bin/sh" 35 | Created : 14 hours ago 36 | Status : Up 14 hours 37 | Ports : 38 | Name : alpine_shell 39 | Size : 0 40 | 41 | Id : c3f015b67195997beaac3ea8f238d3b267ed0d97526614ddf47ffb793c011b6b 42 | Image : debian:buster-slim 43 | Command : "bash" 44 | Created : 14 hours ago 45 | Status : Up 14 hours 46 | Ports : 47 | Name : debian_shell 48 | Size : 0 49 | ``` 50 | 51 | This example returns the currently running containers. 52 | 53 | ## PARAMETERS 54 | 55 | ### None 56 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Optimize-DockerVolume.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Optimize-DockerVolume.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Optimize-DockerVolume 9 | 10 | ## SYNOPSIS 11 | 12 | Remove all unused local volumes. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Optimize-DockerVolume [-Force] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Optimize-DockerVolume function removes all unused local volumes. Once removed, there is no way to recover the volume. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Optimize-DockerVolume 30 | 31 | WARNING! This will remove all local volumes not used by at least one container. 32 | Are you sure you want to continue? [y/N] y 33 | Deleted Volumes: 34 | Test1 35 | Test2 36 | Test3 37 | 38 | Total reclaimed space: 10B 39 | ``` 40 | 41 | This example removes all unused Docker volumes. 42 | 43 | ## PARAMETERS 44 | 45 | ### -Force 46 | 47 | Specify not to prompt for confirmation. 48 | 49 | ```yaml 50 | Type: SwitchParameter 51 | Parameter Sets: (All) 52 | Aliases: 53 | 54 | Required: False 55 | Position: Named 56 | Default value: None 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/docs/Get-AnsibleConfigFile.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForAnsible-help.xml 3 | Module Name: PowershellForAnsible 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForAnsible/docs/Get-AnsibleConfigFile.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-AnsibleConfigFile 9 | 10 | ## SYNOPSIS 11 | 12 | Display the ansible.cfg file. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-AnsibleConfigFile 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-AnsibleConfigFile function displays the ansible.cfg file. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-AnsibleConfigFile 30 | Using /etc/ansible/ansible.cfg as config file 31 | [defaults] 32 | duplicate_dict_key = error 33 | error_on_undefined_vars = true 34 | gathering = smart 35 | host_key_checking = false 36 | inventory = ./inventories/hosts.ini 37 | log_path = ./ansible.log 38 | roles_path = ./roles 39 | callback_result_format = yaml 40 | use_persistent_connections = true 41 | verbosity = 1 42 | 43 | [connection] 44 | pipelining = true 45 | 46 | [ssh_connection] 47 | pipelining = true 48 | 49 | [diff] 50 | always = true 51 | ``` 52 | 53 | This example displays the ansible.cfg file. 54 | -------------------------------------------------------------------------------- /Modules/VirtualDevelopment/VirtualDevelopment.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'VirtualDevelopment.psm1' 3 | ModuleVersion = '2212.7.1' 4 | Description = "A collection of commands to create and manage my development virtual machine." 5 | GUID = '3d789869-88e4-46e8-a9f8-8cd1f8652e10' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @() 10 | RequiredAssemblies = @() 11 | ScriptsToProcess = @() 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | NestedModules = @() 15 | FunctionsToExport = @( 16 | "Install-DevVmPackage" 17 | "New-DevVM" 18 | "New-LinuxDevVM" 19 | "Update-DevVmPackages" 20 | ) 21 | CmdletsToExport = @() 22 | VariablesToExport = @() 23 | AliasesToExport = @() 24 | PrivateData = @{ 25 | PSData = @{ 26 | Tags = @( 27 | "dcjulian29" 28 | "Hyper-V" 29 | "hyperv" 30 | "choco" 31 | "devvm" 32 | "developer" 33 | ) 34 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 35 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 36 | RequireLicenseAcceptance = $false 37 | ExternalModuleDependencies = @() 38 | } 39 | } 40 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/VirtualDevelopment' 41 | } 42 | -------------------------------------------------------------------------------- /Modules/Networking/Wireshark.psm1: -------------------------------------------------------------------------------- 1 | function Find-TShark { 2 | First-Path ` 3 | (Find-ProgramFiles 'Wireshark\tshark.exe') 4 | } 5 | 6 | function Invoke-TShark { 7 | if (-not (Test-Path $(Find-TShark))) { 8 | Write-Output "Wireshark is not installed on this system." 9 | } else { 10 | $param = "$args" 11 | 12 | $ea = $ErrorActionPreference 13 | $ErrorActionPreference = "SilentlyContinue" 14 | 15 | cmd.exe /c "`"$(Find-TShark)`" $param" 16 | 17 | $ErrorActionPreference = $ea 18 | } 19 | } 20 | 21 | Set-Alias tshark Invoke-TShark 22 | 23 | function Get-TSharkInterfaces { 24 | Invoke-TShark -D 25 | } 26 | 27 | Set-Alias tshark-showinterfaces Get-TSharkInterfaces 28 | 29 | function Invoke-TSharkCapture { 30 | param ( 31 | [Parameter(Mandatory=$true)] 32 | [ValidateNotNullOrEmpty()] 33 | [int]$Interface, 34 | [Parameter(Mandatory=$true)] 35 | [ValidateNotNullOrEmpty()] 36 | [string]$Filter, 37 | [Parameter(Mandatory=$true)] 38 | [string]$FileName 39 | ) 40 | 41 | Write-Output "Capture will start in new window... Press Ctrl-C to stop capture." 42 | 43 | $param = "-i $Interface -f `"$Filter`" -w $FileName -N mt" 44 | 45 | Start-Process -FilePath $(Find-TShark) -ArgumentList $param -Wait 46 | } 47 | 48 | Set-Alias tshark-capture Invoke-TSharkCapture 49 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Remove-DockerVolume.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Remove-DockerVolume.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-DockerVolume 9 | 10 | ## SYNOPSIS 11 | 12 | Remove a Docker volume. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Remove-DockerVolume [-Name] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Remove-DockerVolume removes a Docker volume. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Remove-DockerVolume -Name Test6 30 | 31 | Test6 32 | ``` 33 | 34 | This example removes the specified Docker volume. 35 | 36 | ## PARAMETERS 37 | 38 | ### -Name 39 | 40 | Specify the name of the Docker volume. 41 | 42 | ```yaml 43 | Type: String 44 | Parameter Sets: (All) 45 | Aliases: 46 | 47 | Required: True 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: False 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### CommonParameters 55 | 56 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 57 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Optimize-DockerNetwork.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Optimize-DockerNetwork.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Optimize-DockerNetwork 9 | 10 | ## SYNOPSIS 11 | 12 | Remove all unused Docker networks. 13 | 14 | ## SYNTAX 15 | 16 | ```Powershell 17 | Optimize-DockerNetwork [-Force] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Optimize-DockerNetwork function removes all unused Docker networks. An option to force the removal is also available. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Optimize-DockerNetwork 30 | 31 | WARNING! This will remove all custom networks not used by at least one container. 32 | Are you sure you want to continue? [y/N] y 33 | Deleted Networks: 34 | dokuwiki_default 35 | mynet 36 | httpd_default 37 | portainer_default 38 | ``` 39 | 40 | This example removes all of the unused Docker networks that are not used by at least one container. 41 | 42 | ## PARAMETERS 43 | 44 | ### -Force 45 | 46 | Specify that the network should be removed by force if necessary. 47 | 48 | ```yaml 49 | Type: SwitchParameter 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: Named 55 | Default value: None 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | -------------------------------------------------------------------------------- /Modules/TextFormatting/TextFormatting.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'TextFormatting.psm1' 3 | ModuleVersion = '2305.18.1' 4 | Description = "A collection of commands to interact with text formats." 5 | GUID = '1827839b-9a40-473b-bf01-2f4141ecadc1' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @( 10 | @{ 11 | ModuleName = "Filesystem" 12 | ModuleVersion = "2301.10.1" 13 | GUID = "aaad40aa-30a0-495c-8377-53e89ea1ec11" 14 | } 15 | ) 16 | RequiredAssemblies = @() 17 | ScriptsToProcess = @() 18 | TypesToProcess = @() 19 | FormatsToProcess = @() 20 | NestedModules = @() 21 | FunctionsToExport = @( 22 | "Format-Xml" 23 | "Format-Json" 24 | "Convert" 25 | ) 26 | CmdletsToExport = @() 27 | VariablesToExport = @() 28 | AliasesToExport = @() 29 | PrivateData = @{ 30 | PSData = @{ 31 | Tags = @( 32 | "dcjulian29" 33 | "text" 34 | "format" 35 | "conversion" 36 | ) 37 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 38 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 39 | RequireLicenseAcceptance = $false 40 | ExternalModuleDependencies = @() 41 | } 42 | } 43 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/TextFormatting' 44 | } 45 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Remove-DockerNetwork.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Remove-DockerNetwork.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-DockerNetwork 9 | 10 | ## SYNOPSIS 11 | 12 | Remove a Docker network. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Remove-DockerNetwork [-Name] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Remove-DockerNetwork function removes a Docker network. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Remove-DockerNetwork -Name "gatenet" 30 | 31 | gatenet 32 | ``` 33 | 34 | This example deletes the Docker network named gatenet. 35 | 36 | ## PARAMETERS 37 | 38 | ### -Name 39 | 40 | Specify the name of the Docker network. 41 | 42 | ```yaml 43 | Type: String 44 | Parameter Sets: (All) 45 | Aliases: 46 | 47 | Required: True 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: False 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### CommonParameters 55 | 56 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 57 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/docs/Edit-AnsibleVault.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForAnsible-help.xml 3 | Module Name: PowershellForAnsible 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForAnsible/docs/Edit-AnsibleVault.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Edit-AnsibleVault 9 | 10 | ## SYNOPSIS 11 | 12 | Edit an Ansible vault. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Edit-AnsibleVault [[-Vault] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Edit-AnsibleVault function uses the ansible-vault command to edit an Ansbile vault file. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Edit-AnsibleVault 30 | ``` 31 | 32 | This example edits the default secrets.yml file via ansible-vault. 33 | 34 | ## PARAMETERS 35 | 36 | ### -Vault 37 | 38 | Specify the path the the vault YAML file. 39 | 40 | ```yaml 41 | Type: String 42 | Parameter Sets: (All) 43 | Aliases: 44 | 45 | Required: False 46 | Position: 0 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### CommonParameters 53 | 54 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 55 | -------------------------------------------------------------------------------- /Modules/VirtualBaseDisk/VirtualBaseDisk.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'VirtualBaseDisk.psm1' 3 | ModuleVersion = '2212.7.1' 4 | Description = "A collection of commands to create Windows VHDX file that can be used with differencing disks." 5 | GUID = 'ed6e65e3-8813-426c-aa4c-b0373081f509' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @() 10 | RequiredAssemblies = @() 11 | ScriptsToProcess = @() 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | NestedModules = @() 15 | FunctionsToExport = @( 16 | "Get-WindowsImagesInISO" 17 | "Get-WindowsImagesInWIM" 18 | "New-BaseVhdxDisk" 19 | "New-BaseServerVhdxDisk" 20 | "New-DevBaseVhdxDisk" 21 | ) 22 | CmdletsToExport = @() 23 | VariablesToExport = @() 24 | AliasesToExport = @() 25 | PrivateData = @{ 26 | PSData = @{ 27 | Tags = @( 28 | "dcjulian29" 29 | "Hyper-V" 30 | "hyperv" 31 | "vhdx" 32 | "iso" 33 | "wim" 34 | ) 35 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 36 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 37 | RequireLicenseAcceptance = $false 38 | ExternalModuleDependencies = @() 39 | } 40 | } 41 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/VirtualBaseDisk' 42 | } 43 | -------------------------------------------------------------------------------- /Modules/PSModules/PSModules.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'PSModules.psm1' 3 | ModuleVersion = '2301.13.1' 4 | Description = "A collection of utilities, commands, and functions specific to Powershell modules." 5 | GUID = 'c4d33743-f3f8-4dde-a8ff-78c7934497af' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @() 10 | RequiredAssemblies = @() 11 | ScriptsToProcess = @() 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | NestedModules = @() 15 | FunctionsToExport = @( 16 | "Get-InstalledModuleReport" 17 | "Optimize-InstalledModules" 18 | "Reset-Module" 19 | "Restart-Module" 20 | "Update-InstalledModules" 21 | "Update-PreCompiledAssemblies" 22 | ) 23 | CmdletsToExport = @() 24 | VariablesToExport = @() 25 | AliasesToExport = @( 26 | "Reload-Module" 27 | "Remove-OutdatedModules" 28 | "Unload-Module" 29 | ) 30 | PrivateData = @{ 31 | PSData = @{ 32 | Tags = @( 33 | "dcjulian29" 34 | "PSModules" 35 | ) 36 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 37 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 38 | RequireLicenseAcceptance = $false 39 | ExternalModuleDependencies = @() 40 | } 41 | } 42 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/PSModules' 43 | } 44 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitEnvironments.psm1: -------------------------------------------------------------------------------- 1 | function Publish-GitRepositoryToPROD { 2 | [CmdletBinding(DefaultParameterSetName="QA")] 3 | param ( 4 | [Parameter(ParameterSetName="UAT")] 5 | [switch] $FromUAT, 6 | [Parameter(ParameterSetName="QA")] 7 | [switch] $FromQA 8 | ) 9 | 10 | if ( -not ($FromUAT -or $FromQA)) { 11 | throw "You must select an environment to publish from." 12 | } 13 | 14 | $date = [DateTime]::Now.ToString("MMMM d, yyyy ""at"" h:mm ""GMT""zzz") 15 | 16 | & "$(Find-Git)" checkout prod 17 | 18 | if ($FromQA) { 19 | $commit = "Publish QA to Production on $date" 20 | & "$(Find-Git)" merge --no-ff qa -m $commit 21 | } else { 22 | $commit = "Publish UAT to Production on $date" 23 | & "$(Find-Git)" merge --no-ff uat -m $commit 24 | } 25 | } 26 | 27 | function Publish-GitRepositoryToQA { 28 | 29 | $tag = & $(Find-Git) lasttag 30 | $date = [DateTime]::Now.ToString("MMMM d, yyyy ""at"" h:mm ""GMT""zzz") 31 | 32 | $commit = "Publish $tag to QA on $date" 33 | 34 | & "$(Find-Git)" checkout qa 35 | 36 | & "$(Find-Git)" merge --no-ff master -m $commit 37 | } 38 | 39 | function Publish-GitRepositoryToUAT { 40 | $date = [DateTime]::Now.ToString("MMMM d, yyyy ""at"" h:mm ""GMT""zzz") 41 | 42 | $commit = "Publish QA to UAT on $date" 43 | 44 | & "$(Find-Git)" checkout uat 45 | 46 | & "$(Find-Git)" merge --no-ff qa -m $commit 47 | } 48 | -------------------------------------------------------------------------------- /Modules/OperatingSystem/OperatingSystem.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'OperatingSystem.psm1' 3 | ModuleVersion = '2301.7.1' 4 | GUID = '3ffbac72-4374-43f7-8b6d-f190478077e7' 5 | Author = 'Julian Easterling' 6 | PowerShellVersion = '3.0' 7 | TypesToProcess = @() 8 | FormatsToProcess = @() 9 | FunctionsToExport = @( 10 | "Find-UwpApp" 11 | "Get-InstalledFont" 12 | "Get-InstalledSoftware" 13 | "Get-Midnight" 14 | "Get-OSActivationStatus" 15 | "Get-OSArchitecture" 16 | "Get-OSBoot" 17 | "Get-OSBuildNumber" 18 | "Get-OSCaption" 19 | "Get-OSInstallDate" 20 | "Get-OSRegisteredOrganization" 21 | "Get-OSRegisteredUser" 22 | "Get-OSVersion" 23 | "Get-UwpApp" 24 | "Get-UwpAppManifest" 25 | "Install-Font" 26 | "Install-WindowsUpdates" 27 | "New-UwpAppShortcut" 28 | "Remove-EnvironmentVariable" 29 | "Set-EnvironmentVariable" 30 | "Set-Tls13Client" 31 | "Start-UwpApp" 32 | "Test-DaylightSavingsInEffect" 33 | "Test-DomainJoined" 34 | "Test-EnvironmentVariable" 35 | "Test-NormalBoot" 36 | "Test-Os64Bit" 37 | "Test-OsClient" 38 | "Test-OsDomainController" 39 | "Test-OsServer" 40 | "Test-PendingReboot" 41 | "Test-UnixPath" 42 | "Test-WindowsPath" 43 | ) 44 | AliasesToExport = @( 45 | "midnight" 46 | ) 47 | } 48 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/docs/Export-AnsibleFacts.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForAnsible-help.xml 3 | Module Name: PowershellForAnsible 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForAnsible/docs/Export-AnsibleFacts.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Export-AnsibleFacts 9 | 10 | ## SYNOPSIS 11 | 12 | Export a host's Ansible facts. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Export-AnsibleFacts [[-ComputerName] ] [[-InventoryFile] ] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Export-AnsibleFacts function export a host's Ansible facts to a JSON file. These files can then be used by any tool that understands JSON to work with the facts. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Export-AnsibleFacts -ComputerName kibana 30 | ``` 31 | 32 | This example exports the facts of the host named kibana. 33 | 34 | ## PARAMETERS 35 | 36 | ### -ComputerName 37 | 38 | Specify the name of the host. 39 | 40 | ```yaml 41 | Type: String 42 | Parameter Sets: (All) 43 | Aliases: 44 | 45 | Required: False 46 | Position: 0 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### -InventoryFile 53 | 54 | Specify the path to the inventory file. 55 | 56 | ```yaml 57 | Type: String 58 | Parameter Sets: (All) 59 | Aliases: 60 | 61 | Required: False 62 | Position: 1 63 | Default value: None 64 | Accept pipeline input: False 65 | Accept wildcard characters: False 66 | ``` 67 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerContainerIds.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerContainerIds.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerContainerIds 9 | 10 | ## SYNOPSIS 11 | 12 | Get container IDs. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-DockerContainerIds [-Running] [-NoTruncate] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-DockerContainerIds function gets and outputs the ID(s) of Docker containers. By default, the ID are truncated but can be output without truncation. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-DockerContainerIds 30 | 31 | d13a1b3408c9 32 | c3f015b67195 33 | ``` 34 | 35 | This example returns the two IDs for the two containers that are running. 36 | 37 | ## PARAMETERS 38 | 39 | ### -NoTruncate 40 | 41 | Don't truncate output. 42 | 43 | ```yaml 44 | Type: SwitchParameter 45 | Parameter Sets: (All) 46 | Aliases: 47 | 48 | Required: False 49 | Position: Named 50 | Default value: None 51 | Accept pipeline input: False 52 | Accept wildcard characters: False 53 | ``` 54 | 55 | ### -Running 56 | 57 | Limit to only running containers. 58 | 59 | ```yaml 60 | Type: SwitchParameter 61 | Parameter Sets: (All) 62 | Aliases: 63 | 64 | Required: False 65 | Position: Named 66 | Default value: None 67 | Accept pipeline input: False 68 | Accept wildcard characters: False 69 | ``` 70 | -------------------------------------------------------------------------------- /Modules/PSModules/docs/Reset-Module.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSModules-help.xml 3 | Module Name: PSModules 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSModules/docs/Reset-Module.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Reset-Module 9 | 10 | ## SYNOPSIS 11 | 12 | Unload a Powershell module loaded into the current session. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Reset-Module [-Name] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Reset-Module command unloads a module if it is loaded within the current Powershell session. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Reset-Module -Name Powershell 30 | ``` 31 | 32 | This example unloads the Powershell module if it is loaded. 33 | 34 | ## PARAMETERS 35 | 36 | ### -Name 37 | 38 | Specifies the name of the module. 39 | 40 | ```yaml 41 | Type: String 42 | Parameter Sets: (All) 43 | Aliases: ModuleName 44 | 45 | Required: True 46 | Position: 0 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### CommonParameters 53 | 54 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 55 | 56 | ## INPUTS 57 | 58 | ## OUTPUTS 59 | 60 | ## NOTES 61 | 62 | ## RELATED LINKS 63 | -------------------------------------------------------------------------------- /Modules/Code/Code.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2304.24.1' 3 | GUID = '6aa69e5b-f92d-41ba-947b-7840504d31da' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'Code.psm1' 7 | NestedModules = @( 8 | "CodeBuilding.psm1" 9 | "CodeFolder.psm1" 10 | "CodeManagement.psm1" 11 | ) 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | FunctionsToExport = @( 15 | "Get-CakeBuildBootstrapper" 16 | "Get-CodeCoverageReport" 17 | "Get-DefaultCodeFolder" 18 | "Get-MsBuildErrorsFromLog" 19 | "Get-UnitTestReport" 20 | "Edit-StyleCopSettings" 21 | "Find-MSBuild" 22 | "Find-StyleCopSettingsEditor" 23 | "Import-DevelopmentPowerShellModule" 24 | "Invoke-ArchiveProject" 25 | "Invoke-BuildProject" 26 | "Invoke-CleanAllProjects" 27 | "Invoke-CleanProject" 28 | "Invoke-MSBuild" 29 | "Invoke-SortConfigurationFile" 30 | "Invoke-SortProjectFile" 31 | "New-CodeFolder" 32 | "Set-CodeFolder" 33 | "Set-DefaultCodeFolder" 34 | "Show-CodeStatus" 35 | "Show-CoverageReport" 36 | "Test-DefaultCodeFolder" 37 | "Update-CodeFolder" 38 | ) 39 | AliasesToExport = @( 40 | "bp" 41 | "idpsm" 42 | "msbuild" 43 | "project-archive" 44 | "project-clean" 45 | "project-clean-all" 46 | "Sort-ConfigurationFile" 47 | "Sort-ProjectFile" 48 | ) 49 | } 50 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Invoke-DockerContainerShell.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Invoke-DockerContainerShell.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-DockerContainerShell 9 | 10 | ## SYNOPSIS 11 | 12 | Invoke a container shell to interact with it. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Invoke-DockerContainerShell [-Id] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Invoke-DockerContainerShell function attaches interactively to a container. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Invoke-DockerContainerShell -Id c3f015b 30 | # 31 | ``` 32 | 33 | This example invokes the shell on the specified container. 34 | 35 | ## PARAMETERS 36 | 37 | ### -Id 38 | 39 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 40 | 41 | ```yaml 42 | Type: String 43 | Parameter Sets: (All) 44 | Aliases: 45 | 46 | Required: True 47 | Position: 0 48 | Default value: None 49 | Accept pipeline input: False 50 | Accept wildcard characters: False 51 | ``` 52 | 53 | ### CommonParameters 54 | 55 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 56 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Create and publish my packages 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'choco/dcjulian29.psmodules/**' 7 | - 'Modules/**' 8 | 9 | pull_request: 10 | types: [opened, reopened] 11 | paths: 12 | - 'choco/dcjulian29.psmodules/**' 13 | - 'modules/**' 14 | 15 | workflow_dispatch: 16 | 17 | jobs: 18 | build: 19 | runs-on: windows-2022 20 | 21 | steps: 22 | - uses: actions/checkout@v6 23 | 24 | - name: Setup NuGet 25 | uses: NuGet/setup-nuget@v2.0.1 26 | 27 | - name: Create individual module packages 28 | run: ./choco/build.ps1 29 | 30 | - name: Create chocolatey package 31 | run: ./choco/dcjulian29.psmodules/build.ps1 32 | 33 | - name: Publish module packages 34 | if: startsWith(github.ref, 'refs/heads/main') 35 | env: 36 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 37 | run: > 38 | Set-Location ${{ github.workspace }}\.packages; 39 | dotnet nuget push **/*.nupkg 40 | --api-key '${{ secrets.NUGET_API_KEY }}' 41 | --source '${{ vars.NUGET_URL }}' 42 | --skip-duplicate 43 | 44 | - name: Publish chocolatey package 45 | if: startsWith(github.ref, 'refs/heads/main') 46 | env: 47 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 48 | run: > 49 | Set-Location ${{ github.workspace }}\.meta; 50 | dotnet nuget push **/*.nupkg 51 | --api-key '${{ secrets.NUGET_API_KEY }}' 52 | --source '${{ vars.CHOCO_URL }}' 53 | --skip-duplicate 54 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitFiles.psm1: -------------------------------------------------------------------------------- 1 | function removeNonExistFiles { 2 | param ( 3 | [string[]] $files 4 | ) 5 | 6 | $returnedFiles = @() 7 | 8 | foreach ($file in $files) { 9 | if (Test-Path $file) { 10 | $returnedFiles += $file 11 | } 12 | } 13 | 14 | return $returnedFiles 15 | } 16 | 17 | function getFileList { 18 | param ( 19 | [string] $CommitId, 20 | [string] $StartCommitId# = "HEAD~1" 21 | ) 22 | 23 | return $(cmd /c """$(Find-Git)"" diff --name-only $CommitId $StartCommitId") 24 | } 25 | 26 | ############################################################################### 27 | 28 | function Get-GitFilesFromCommit { 29 | param ( 30 | [Parameter(Mandatory=$true)] 31 | [string] $CommitId 32 | ) 33 | 34 | return (cmd /c """$(Find-Git)"" log -m -1 --name-only --first-parent --pretty="""" $CommitId") 35 | } 36 | 37 | function Get-GitFilesFromLastCommit { 38 | return removeNonExistFiles ` 39 | (getFileList -CommitId "HEAD" -StartCommitId "HEAD~1") 40 | } 41 | 42 | function Get-GitFilesSinceLastTag { 43 | return removeNonExistFiles ` 44 | (getFileList -CommitId "HEAD" ` 45 | -StartCommitId (Get-LastGitTag)) 46 | } 47 | 48 | function Get-GitFilesSinceTag { 49 | param ( 50 | [Parameter(Mandatory=$true)] 51 | [string] $Tag 52 | ) 53 | 54 | return removeNonExistFiles ` 55 | (getFileList -CommitId (cmd /c """$(Find-Git)"" show-ref --tags --hash $Tag")) 56 | } 57 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/docs/Confirm-AnsiblePlaybookSyntax.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForAnsible-help.xml 3 | Module Name: PowershellForAnsible 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForAnsible/docs/Confirm-AnsiblePlaybookSyntax.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Confirm-AnsiblePlaybookSyntax 9 | 10 | ## SYNOPSIS 11 | 12 | Confirm that a playbook is syntactically correct. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Confirm-AnsiblePlaybookSyntax [-PlaybookPath] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Confirm-AnsiblePlaybookSyntax function runs a syntax check on the specified playbook. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Confirm-AnsiblePlaybookSyntax -PlaybookPath ./playbooks/elk.yml 30 | ``` 31 | 32 | This example validates the syntax of the elk.yml playbook. 33 | 34 | ## PARAMETERS 35 | 36 | ### -PlaybookPath 37 | 38 | Specify the path to the playbook. 39 | 40 | ```yaml 41 | Type: String 42 | Parameter Sets: (All) 43 | Aliases: Path, Playbook 44 | 45 | Required: True 46 | Position: 0 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### CommonParameters 53 | 54 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 55 | -------------------------------------------------------------------------------- /Modules/PSModules/docs/Restart-Module.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSModules-help.xml 3 | Module Name: PSModules 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/Powershell/docs/Restart-Module.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Restart-Module 9 | 10 | ## SYNOPSIS 11 | 12 | Import a Powershell module after unloading it if it is loaded. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Restart-Module [-Name] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Restart-Module cmdlet will unload a Powershell module with the same name before attempting to import the specified module. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Restart-Module -Name Powershell 30 | ``` 31 | 32 | This example will unload the module, if loaded, before importing the module. 33 | 34 | ## PARAMETERS 35 | 36 | ### -Name 37 | 38 | Specifies the name of the module. 39 | 40 | ```yaml 41 | Type: String 42 | Parameter Sets: (All) 43 | Aliases: ModuleName 44 | 45 | Required: True 46 | Position: 0 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### CommonParameters 53 | 54 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 55 | 56 | ## INPUTS 57 | 58 | ## OUTPUTS 59 | 60 | ## NOTES 61 | 62 | ## RELATED LINKS 63 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Get-LastExecutionTime.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Get-LastExecutionTime.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-LastExecutionTime 9 | 10 | ## SYNOPSIS 11 | 12 | Return the elapsed time of the last command. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-LastExecutionTime [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-LastExecutionTime cmdlet returns the elapsed time of the last command executed. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-LastExecutionTime 30 | 31 | Days : 0 32 | Hours : 0 33 | Minutes : 0 34 | Seconds : 1 35 | Milliseconds : 716 36 | Ticks : 17161638 37 | TotalDays : 1.98630069444444E-05 38 | TotalHours : 0.000476712166666667 39 | TotalMinutes : 0.02860273 40 | TotalSeconds : 1.7161638 41 | TotalMilliseconds : 1716.1638 42 | ``` 43 | 44 | This example returns the elapsed time of the last command. 45 | 46 | ## PARAMETERS 47 | 48 | ### CommonParameters 49 | 50 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 51 | 52 | ## INPUTS 53 | 54 | ## OUTPUTS 55 | 56 | ## NOTES 57 | 58 | ## RELATED LINKS 59 | -------------------------------------------------------------------------------- /Modules/ElasticSearch/ElasticSearch.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2307.23.1' 3 | GUID = '9b8cce35-7dda-4746-b7b0-ba340ef3185a' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'ElasticSearch.psm1' 7 | NestedModules = @( 8 | 'ElasticSearchCluster.psm1' 9 | 'ElasticSearchDocument.psm1' 10 | 'ElasticSearchIndex.psm1' 11 | ) 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | FunctionsToExport = @( 15 | "Clear-ElasticSearchProfile" 16 | "Find-ElasticSearchDocument" 17 | "Get-ElasticSearchDocument" 18 | "Get-ElasticSearchHealth" 19 | "Get-ElasticSearchIndex" 20 | "Get-ElasticSearchIndexDocumentCount" 21 | "Get-ElasticSearchNode" 22 | "Get-ElasticSearchNodeDetail" 23 | "Get-ElasticSearchState" 24 | "Get-ElasticSearchStatistic" 25 | "Import-ElasticSearchProfile" 26 | "Invoke-ElasticSearchApi" 27 | "New-ElasticSearchDocument" 28 | "New-ElasticSearchProfile" 29 | "Remove-ElasticSearchDocument" 30 | "Set-ElasticSearchProfile" 31 | "Test-ElasticSearchIndex" 32 | "Test-ElasticSearchProfile" 33 | "Update-ElasticSearchDocument" 34 | "Use-ElasticSearchProfile" 35 | ) 36 | AliasesToExport = @( 37 | "Load-ElasticSearchProfile" 38 | "es-api" 39 | "elasticsearch-api" 40 | "elasticsearch-profile-clear" 41 | "es-profile-clear" 42 | "elasticsearch-profile-load" 43 | "es-profile-load" 44 | ) 45 | } 46 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Import-Assembly.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Import-Assembly.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Import-Assembly 9 | 10 | ## SYNOPSIS 11 | 12 | Import a .Net Assembly. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Import-Assembly [[-Assembly] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Import-Assembly imports a .Net assembly based on the name of the assembly file or the name of assembly if loading from GAC. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Import-Assembly -Assembly "System.Text" 30 | ``` 31 | 32 | This example imports the System.Text assembly from the GAC. 33 | 34 | ## PARAMETERS 35 | 36 | ### -Assembly 37 | 38 | Specifies the name of the assembly file or the name of assembly if loading from GAC. 39 | 40 | ```yaml 41 | Type: String 42 | Parameter Sets: (All) 43 | Aliases: 44 | 45 | Required: False 46 | Position: 0 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### CommonParameters 53 | 54 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 55 | 56 | ## INPUTS 57 | 58 | ## OUTPUTS 59 | 60 | ## NOTES 61 | 62 | ## RELATED LINKS 63 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Connect-DockerContainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Connect-DockerContainer.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Connect-DockerContainer 9 | 10 | ## SYNOPSIS 11 | 12 | Attach local standard input, output, and error streams to a running container. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Connect-DockerContainer [-Id] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Connect-DockerContainer attaches the host's standard input, output, and error streams to a running container. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Connect-DockerContainer -Id 03afcf02260f 30 | / # 31 | ``` 32 | 33 | This example attaches to the container identified. 34 | 35 | ## PARAMETERS 36 | 37 | ### -Id 38 | 39 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 40 | 41 | ```yaml 42 | Type: String 43 | Parameter Sets: (All) 44 | Aliases: 45 | 46 | Required: True 47 | Position: 0 48 | Default value: None 49 | Accept pipeline input: False 50 | Accept wildcard characters: False 51 | ``` 52 | 53 | ### CommonParameters 54 | 55 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 56 | -------------------------------------------------------------------------------- /Modules/OpenSSH/OpenSSH.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2412.7.1' 3 | GUID = '2b2add2f-ba2d-461a-8bac-6cfb19894a0d' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'OpenSSH.psm1' 7 | NestedModules = @( 8 | "OpenSCP.psm1" 9 | "OpenSSHConfig.psm1" 10 | "OpenSSHKnownHosts.psm1" 11 | "OpenSSHPackages.psm1" 12 | "OpenSSHServer.psm1" 13 | ) 14 | TypesToProcess = @() 15 | FormatsToProcess = @() 16 | FunctionsToExport = @( 17 | "Add-OpenSSHClient" 18 | "Add-OpenSSHAuthorizedKey" 19 | "Add-OpenSSHServer" 20 | "Add-OpenSSHKnownHost" 21 | "Enable-OpenSSHServer" 22 | "Disable-OpenSSHServer" 23 | "Find-OpenSCP" 24 | "Find-OpenSSH" 25 | "Get-OpenSSHConfigFileName" 26 | "Get-OpenSSHDefaultShell" 27 | "Get-OpenSSHDefaultShellOptions" 28 | "Get-OpenSSHKnownHosts" 29 | "Get-OpenSSHConfig" 30 | "Invoke-OpenSCP" 31 | "Invoke-OpenSSH" 32 | "New-OpenSSHHostShortcut" 33 | "New-OpenSSHKey" 34 | "Receive-OpenSCPPath" 35 | "Remove-OpenSSHClient" 36 | "Remove-OpenSSHServer" 37 | "Remove-OpenSSHKnownHost" 38 | "Send-OpenSCPPath" 39 | "Set-OpenSSHDefaultShell" 40 | "Test-OpenSSHClient" 41 | "Test-OpenSSHServer" 42 | "Test-OpenSSHService" 43 | ) 44 | AliasesToExport = @( 45 | "Execute-OpenSSHCommand" 46 | "Install-OpenSSHServer" 47 | "Invoke-OpenSSHCommand" 48 | "secure-copy" 49 | "secure-copy-receive" 50 | "secure-copy-send" 51 | "ssh-knownhost-add" 52 | "ssh-knownhost-remove" 53 | "sshell" 54 | "sshellc" 55 | ) 56 | } 57 | -------------------------------------------------------------------------------- /Modules/WebCredential/docs/Remove-WebCredential.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: WebCredential-help.xml 3 | Module Name: WebCredential 4 | online version:https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/WebCredential/docs/Remove-WebCredential.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-WebCredential 9 | 10 | ## SYNOPSIS 11 | 12 | Removes named credentials. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Remove-WebCredential [-Name] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | Remove-WebCredential is a Powershell cmdlet for using the Windows OS credential manager to remove a username and password credential. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Remove-WebCredential -Name "test" 30 | ``` 31 | 32 | This example runs the command to remove User1's username and password in 33 | the Web Credential Store in the Windows operating system identified by 34 | the name "test". 35 | 36 | ## PARAMETERS 37 | 38 | ### -Name 39 | 40 | The name of the resource containing the credential. 41 | 42 | ```yaml 43 | Type: String 44 | Parameter Sets: (All) 45 | Aliases: 46 | 47 | Required: True 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: True (ByPropertyName) 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### CommonParameters 55 | 56 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 57 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Pop-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Pop-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Pop-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Pulls image(s) defined in a docker-compose.yml file, but does not start any containers based on those images. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Pop-DockerCompose [[-ComposeFile] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Pop-DockerCompose calls out to docker-compose.exe to pull all images defined in the docker compose file. If the image already exists, no action is done. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Pop-DockerCompose 30 | 31 | Pulling portainer ... done 32 | ``` 33 | 34 | This example pulls the latest Portainer image. 35 | 36 | ## PARAMETERS 37 | 38 | ### -ComposeFile 39 | 40 | Specify a docker compose file. (default: docker-compose.yml) 41 | 42 | ```yaml 43 | Type: String 44 | Parameter Sets: (All) 45 | Aliases: Path 46 | 47 | Required: False 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: False 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### CommonParameters 55 | 56 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 57 | -------------------------------------------------------------------------------- /Modules/PSExtensions/PSExtensions.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'PSExtensions.psm1' 3 | ModuleVersion = '2204.20.1' 4 | Description = "A collection of utilities, commands, and functions specific to extending Powershell." 5 | GUID = '72b96fb6-bfd3-47cc-88ca-39558e0d3fa1' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @() 10 | RequiredAssemblies = @() 11 | ScriptsToProcess = @() 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | NestedModules = @() 15 | FunctionsToExport = @( 16 | "Edit-Profile" 17 | "Get-AvailableExceptionsList" 18 | "Get-LastExecutionTime" 19 | "Get-PowershellVerbs" 20 | "Get-Profile" 21 | "Import-Assembly" 22 | "New-ErrorRecord" 23 | "Remove-AliasesFromScript" 24 | "Search-Command" 25 | "Test-IsNonInteractive" 26 | "Test-PowershellVerb" 27 | "Update-MyProfile" 28 | "Update-Profile" 29 | ) 30 | CmdletsToExport = @() 31 | VariablesToExport = @() 32 | AliasesToExport = @( 33 | "Load-Assembly" 34 | "Find-PSCommand" 35 | "Reload-Profile" 36 | ) 37 | PrivateData = @{ 38 | PSData = @{ 39 | Tags = @( 40 | "dcjulian29" 41 | "PSExtensions" 42 | ) 43 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 44 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 45 | RequireLicenseAcceptance = $false 46 | ExternalModuleDependencies = @() 47 | } 48 | } 49 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/PSExtensions' 50 | } 51 | -------------------------------------------------------------------------------- /Modules/PSModules/docs/Update-InstalledModules.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSModules-help.xml 3 | Module Name: PSModules 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSModules/docs/Update-InstalledModules.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Update-InstalledModules 9 | 10 | ## SYNOPSIS 11 | 12 | Update, if available, modules installed via a repository. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Update-InstalledModules [-Verbose] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Update-InstalledModules cmdlet updates modules installed via a repository. If an update is not available, nothing is done. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Update-InstalledModules 30 | ``` 31 | 32 | This example updates all of the installed modules. 33 | 34 | ## PARAMETERS 35 | 36 | ### -Verbose 37 | 38 | Displays detailed information about the operation done by the command. This information resembles the information in a trace or in a transaction log. 39 | 40 | ```yaml 41 | Type: SwitchParameter 42 | Parameter Sets: (All) 43 | Aliases: 44 | 45 | Required: False 46 | Position: Named 47 | Default value: None 48 | Accept pipeline input: False 49 | Accept wildcard characters: False 50 | ``` 51 | 52 | ### CommonParameters 53 | 54 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 55 | 56 | ## INPUTS 57 | 58 | ## OUTPUTS 59 | 60 | ## NOTES 61 | 62 | ## RELATED LINKS 63 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerVolume.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerVolume.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerVolume 9 | 10 | ## SYNOPSIS 11 | 12 | List Docker volumes. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-DockerVolume [[-Name] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-DockerVolume function list Docker volumes. If a name is provided, the function will display detailed information about the volume. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-DockerVolume -Name test2 30 | 31 | CreatedAt : 2022-02-03T10:35:08Z 32 | Driver : local 33 | Labels : 34 | Mountpoint : /var/lib/docker/volumes/test2/_data 35 | Name : test2 36 | Options : 37 | Scope : local 38 | ``` 39 | 40 | This example shows the detailed information about the specified Docker volume. 41 | 42 | ## PARAMETERS 43 | 44 | ### -Name 45 | 46 | Specify the name of the Docker volume. 47 | 48 | ```yaml 49 | Type: String 50 | Parameter Sets: (All) 51 | Aliases: 52 | 53 | Required: False 54 | Position: 0 55 | Default value: None 56 | Accept pipeline input: False 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### CommonParameters 61 | 62 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 63 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitFlowFeature.psm1: -------------------------------------------------------------------------------- 1 | function Pop-GitFlowFeature { 2 | param ( 3 | [string] $Name = "$(Read-Host 'What is the name of the feature')" 4 | ) 5 | 6 | & "$(Find-Git)" flow feature pull $Name 7 | } 8 | 9 | Set-Alias Pull-GitFlowFeature Pop-GitFlowFeature 10 | 11 | function Publish-GitFlowFeature { 12 | param ( 13 | [string] $Name = "$(Read-Host 'What is the name of the feature')" 14 | ) 15 | 16 | & "$(Find-Git)" flow feature publish $Name 17 | } 18 | 19 | function Remove-GitFlowFeature { 20 | & "$(Find-Git)" fetch 21 | & "$(Find-Git)" flow feature delete --remote 22 | & "$(Find-Git)" checkout develop 23 | & "$(Find-Git)" pull 24 | } 25 | 26 | Set-Alias Abort-GitFlowFeature Remove-GitFlowFeature 27 | 28 | function Start-GitFlowFeature { 29 | param ( 30 | [string] $Name = "$(Read-Host 'What is the name of the feature')" 31 | ) 32 | 33 | & "$(Find-Git)" flow feature start $Name 34 | } 35 | 36 | Set-Alias gffs Start-GitFlowFeature 37 | 38 | function Stop-GitFlowFeature { 39 | & "$(Find-Git)" flow feature finish 40 | } 41 | 42 | Set-Alias gfff Stop-GitFlowFeature 43 | Set-Alias Finish-GitFlowFeature Stop-GitFlowFeature 44 | 45 | function Update-GitFlowFeature { 46 | $branch = $(Get-GitRepositoryBranch).ToLowerInvariant() 47 | 48 | if (-not $branch.StartsWith("feature/")) { 49 | Write-Error "You are not in a GitFlow Feature branch." 50 | } else { 51 | Write-Output "Making Sure that local branches or up-to-date..." 52 | & "$(Find-Git)" checkout develop 53 | & "$(Find-Git)" pull origin 54 | & "$(Find-Git)" checkout $branch 55 | & "$(Find-Git)" pull origin 56 | & "$(Find-Git)" merge develop --no-ff 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Modules/Networking/Watch-DefaultGatewayChangeVpn.ps1: -------------------------------------------------------------------------------- 1 | Function Watch-DefaultGatewayChangeVpn($IfName) { 2 | $adapter = Get-NetAdapter | Where-Object { $_.Name -eq $IfName } 3 | if ($adapter.Status -eq "Up") { 4 | while ($true) { 5 | $routes = Get-WmiObject -Class Win32_IP4RouteTable ` 6 | | Where-Object { $_.destination -eq '0.0.0.0' -and $_.mask -eq '0.0.0.0'} ` 7 | | Sort-Object metric1 | Select-Object nexthop, metric1, interfaceindex 8 | 9 | Write-Host $([DateTime]::Now),$routes.nexthop 10 | 11 | if ($routes.interfaceindex -ne $adapter.ifIndex) { 12 | $adapter | Disable-NetAdapter -Confirm:$false 13 | 14 | $connectedAdapters = Get-NetAdapter | Where-Object { $_.Status -eq "Up" } 15 | 16 | foreach ($gateway in $connectedAdapters) { 17 | $gateway | Disable-NetAdapter -Confirm:$false 18 | } 19 | 20 | $adapter | Enable-NetAdapter 21 | 22 | ShowPopUpVpn "Default Gateway is not currently set to the VPN adapter!" 23 | 24 | foreach ($gateway in $connectedAdapters) { 25 | $gateway | Enable-NetAdapter 26 | } 27 | 28 | ShowPopUpVpn "Click Ok to resume watch." 29 | } 30 | 31 | Start-Sleep -s 15 32 | } 33 | } else { 34 | ShowPopUpVpn "The specified interface is not connected..." 35 | } 36 | } 37 | 38 | Function ShowPopUpVpn($message) { 39 | Write-Warning $message 40 | $shell = New-Object -ComObject "WScript.Shell" 41 | $button = $shell.Popup($message, 0, "Watch VPN Adpater", 0) 42 | } 43 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Remove-AliasesFromScript.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Remove-AliasesFromScript.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-AliasesFromScript 9 | 10 | ## SYNOPSIS 11 | 12 | Remove Powershell aliases from a script file. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Remove-AliasesFromScript [-Path] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Remove-AliasesFromScript allows you to quickly create a Powershell script containing aliases and then remove them and replace them with the cmdlet names. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Remove-AliasesFromScript -Path test1.ps1 30 | 31 | Replacing 'gci' with 'Get-ChildItem'... 32 | Replacing '%' with 'ForEach-Object'... 33 | ``` 34 | 35 | This example replaces any Powershell aliases with their equivalent Powershell command. 36 | 37 | ## PARAMETERS 38 | 39 | ### -Path 40 | 41 | Specifies a path to a Powershell script file. 42 | 43 | ```yaml 44 | Type: String 45 | Parameter Sets: (All) 46 | Aliases: 47 | 48 | Required: True 49 | Position: 0 50 | Default value: None 51 | Accept pipeline input: False 52 | Accept wildcard characters: False 53 | ``` 54 | 55 | ### CommonParameters 56 | 57 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 58 | 59 | ## INPUTS 60 | 61 | ## OUTPUTS 62 | 63 | ## NOTES 64 | 65 | ## RELATED LINKS 66 | -------------------------------------------------------------------------------- /Modules/ElasticSearch/ElasticSearchCluster.psm1: -------------------------------------------------------------------------------- 1 | function Get-ElasticSearchHealth { 2 | Invoke-ElasticSearchApi "_cluster/health" 3 | } 4 | 5 | function Get-ElasticSearchNode { 6 | param ( 7 | [string] $Node, 8 | [string] $Filter 9 | ) 10 | 11 | $result = Invoke-ElasticSearchApi "_cat/nodes?v&pretty" 12 | 13 | if ($Node) { 14 | $result = $result | Where-Object { $_.name -eq $Node } 15 | } 16 | 17 | if ($Filter) { 18 | $result = $result | Where-Object { $_.name -like "*$Filter*" } 19 | } 20 | 21 | return $result 22 | } 23 | 24 | function Get-ElasticSearchNodeDetail { 25 | param ( 26 | [string] $Node, 27 | [switch] $All, 28 | [switch] $Local, 29 | [switch] $Master 30 | ) 31 | 32 | $method = "_nodes" 33 | 34 | if ($node) { 35 | $method += "/$Node" 36 | } else { 37 | if ($All) { 38 | $method += "/_all" 39 | } else { 40 | if ($Master) { 41 | $method += "/_master" 42 | } else { 43 | if ($Local) { 44 | $method += "/_local" 45 | } 46 | } 47 | } 48 | } 49 | 50 | $result = Invoke-ElasticSearchApi $method 51 | 52 | if ($null -ne $result.nodes) { 53 | $details = @() 54 | $keys = ($result.nodes[0] | Get-Member -MemberType NoteProperty).Name 55 | 56 | foreach ($key in $keys) { 57 | $details += ($result.nodes | Select-Object $key).PSObject.Properties.Value 58 | } 59 | 60 | $result = $details 61 | } 62 | 63 | return $result 64 | } 65 | 66 | function Get-ElasticSearchState { 67 | Invoke-ElasticSearchApi "_cluster/state" 68 | } 69 | 70 | function Get-ElasticSearchStatistic { 71 | Invoke-ElasticSearchApi "_cluster/state" 72 | } 73 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Test-PowershellVerb.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Test-PowershellVerb.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-PowershellVerb 9 | 10 | ## SYNOPSIS 11 | 12 | Test if a verb is an approved Powershell verb. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Test-PowershellVerb [-Verb] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Test-PowershellVerb is a way to test if the specified verb is on the approved list. While Powershell doesn't prevent someone from using a non-approved verb in cmdlets, it does generate warnings when imported. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Test-PowershellVerb -Verb Get 30 | True 31 | ``` 32 | 33 | This example returns true because 'get' is an approved Powershell verb. 34 | 35 | ### Example 2 36 | 37 | ```powershell 38 | PS C:\> Test-PowershellVerb -Verb Unload 39 | False 40 | ``` 41 | 42 | This example returns false because 'unload' is not an approved Powershell verb. 43 | 44 | ## PARAMETERS 45 | 46 | ### -Verb 47 | 48 | Specifies the name of the Powershell verb to test. 49 | 50 | ```yaml 51 | Type: String 52 | Parameter Sets: (All) 53 | Aliases: 54 | 55 | Required: True 56 | Position: 0 57 | Default value: None 58 | Accept pipeline input: False 59 | Accept wildcard characters: False 60 | ``` 61 | 62 | ### CommonParameters 63 | 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ## OUTPUTS 69 | 70 | ## NOTES 71 | 72 | ## RELATED LINKS 73 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Start-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Start-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Start-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Builds, (re)creates, and starts containers specified in the Compose file. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Start-DockerCompose [[-ComposeFile] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Start-DockerCompose function calls the docker compose up command using the specified Compose file. 23 | 24 | If there are existing containers for a service, and the service’s configuration or image was changed after the container’s creation, docker compose picks up the changes by stopping and recreating the containers (preserving mounted volumes). 25 | 26 | ## EXAMPLES 27 | 28 | ### Example 1 29 | 30 | ```powershell 31 | PS C:\> Start-DockerCompose 32 | 33 | Creating network "portainer_default" with the default driver 34 | Creating portainer_portainer_1 ... done 35 | ``` 36 | 37 | This example starts a Portainer container. 38 | 39 | ## PARAMETERS 40 | 41 | ### -ComposeFile 42 | 43 | Specify a docker compose file. (default: docker-compose.yml) 44 | 45 | ```yaml 46 | Type: String 47 | Parameter Sets: (All) 48 | Aliases: Path 49 | 50 | Required: False 51 | Position: 0 52 | Default value: None 53 | Accept pipeline input: False 54 | Accept wildcard characters: False 55 | ``` 56 | 57 | ### CommonParameters 58 | 59 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 60 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Read-DockerCompose.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Read-DockerCompose.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Read-DockerCompose 9 | 10 | ## SYNOPSIS 11 | 12 | Validate and view the Compose file. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Read-DockerCompose [[-ComposeFile] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Read-DockerCompose function reads a docker compose file, validates it and outputs the validated results. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Read-DockerCompose 30 | 31 | services: 32 | portainer: 33 | environment: 34 | TZ: America/New_York 35 | image: portainer/portainer-ce 36 | ports: 37 | - published: 9000 38 | target: 9000 39 | - published: 8000 40 | target: 8000 41 | volumes: 42 | - /var/run/docker.sock:/var/run/docker.sock:rw 43 | - D:\dockerdata\portainer:/data:rw 44 | version: '3.9' 45 | ``` 46 | 47 | This example validates a docker compose file configured for Portainer and outputs the result. 48 | 49 | ## PARAMETERS 50 | 51 | ### -ComposeFile 52 | 53 | Specify a docker compose file. (default: docker-compose.yml) 54 | 55 | ```yaml 56 | Type: String 57 | Parameter Sets: (All) 58 | Aliases: Path 59 | 60 | Required: False 61 | Position: 0 62 | Default value: None 63 | Accept pipeline input: False 64 | Accept wildcard characters: False 65 | ``` 66 | 67 | ### CommonParameters 68 | 69 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 70 | -------------------------------------------------------------------------------- /Modules/Networking/BindTools.psm1: -------------------------------------------------------------------------------- 1 | function bindContainer { 2 | [CmdletBinding()] 3 | param ( 4 | [string]$Command, 5 | [string]$Arguments, 6 | [string]$Additional 7 | ) 8 | 9 | if (Test-DockerLinuxEngine) { 10 | $params = @{ 11 | Image = "mbentley/bind-tools" 12 | Tag = "latest" 13 | Interactive = $true 14 | Name = "bind_shell" 15 | AdditionalArgs = $Additional 16 | } 17 | 18 | if ($Command) { 19 | $params.Add("Command", "`"$Command`"") 20 | } 21 | 22 | $params.GetEnumerator().ForEach({ Write-Verbose "$($_.Name)=$($_.Value)" }) 23 | 24 | New-DockerContainer @params 25 | } else { 26 | Write-Error "Bind Tools sub-module requires the Linux Docker Engine!" -Category ResourceUnavailable 27 | } 28 | } 29 | 30 | #------------------------------------------------------------------------------ 31 | 32 | function Invoke-Dig { 33 | bindContainer -Command "dig" -Additional "$args" 34 | } 35 | 36 | Set-Alias -Name dig -Value Invoke-Dig 37 | Set-Alias -Name bind-dig -Value Invoke-Dig 38 | 39 | function Invoke-ArpaName { 40 | bindContainer -Command "arpaname" -Additional "$args" 41 | } 42 | 43 | Set-Alias -Name arpaname -Value Invoke-ArpaName 44 | Set-Alias -Name bind-arpaname -Value Invoke-ArpaName 45 | 46 | function Invoke-Host { 47 | bindContainer -Command "host" -Additional "$args" 48 | } 49 | 50 | Set-Alias -Name host -Value Invoke-Host 51 | Set-Alias -Name bind-host -Value Invoke-Host 52 | 53 | function Invoke-NSLookup { 54 | bindContainer -Command "nslookup" -Additional "$args" 55 | } 56 | 57 | Set-Alias -Name lookup -Value Invoke-NSLookup 58 | Set-Alias -Name bind-nslookup -Value Invoke-NSLookup 59 | 60 | function Invoke-NSUpdate { 61 | bindContainer -Command "nsupdate" -Additional "$args" 62 | } 63 | 64 | Set-Alias -Name nsupdate -Value Invoke-NSUpdate 65 | Set-Alias -Name bind-nsupdate -Value Invoke-NSUpdate 66 | -------------------------------------------------------------------------------- /Modules/VirtualBaseDisk/docs/Get-WindowsImagesInISO.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VirtualBaseDisk-help.xml 3 | Module Name: VirtualBaseDisk 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/VirtualBaseDisk/docs/Get-WindowsImagesInISO.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-WindowsImagesInISO 9 | 10 | ## SYNOPSIS 11 | 12 | Gets information about all Windows images in an ISO file. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-WindowsImagesInISO [-IsoFile] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-WindowsImagesInISO cmdlet gets a list of Windows images in an ISO file. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-WindowsImagesInISO Windows11_InsiderPreview_Client_x64_en-us_22533.iso 30 | 31 | # Name 32 | - ---- 33 | 1 Windows 11 Home 34 | 2 Windows 11 Home N 35 | 3 Windows 11 Home Single Language 36 | 4 Windows 11 Education 37 | 5 Windows 11 Education N 38 | 6 Windows 11 Pro 39 | 7 Windows 11 Pro N 40 | 8 Windows 11 Pro Education 41 | 9 Windows 11 Pro Education N 42 | 10 Windows 11 Pro for Workstations 43 | 11 Windows 11 Pro N for Workstations 44 | ``` 45 | 46 | This example list the Windows Images contained in the install.wim file inside the ISO file.. 47 | 48 | ## PARAMETERS 49 | 50 | ### -IsoFile 51 | 52 | Specifies the location of an ISO file. 53 | 54 | ```yaml 55 | Type: String 56 | Parameter Sets: (All) 57 | Aliases: Path 58 | 59 | Required: True 60 | Position: 1 61 | Default value: None 62 | Accept pipeline input: False 63 | Accept wildcard characters: False 64 | ``` 65 | 66 | ### CommonParameters 67 | 68 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 69 | -------------------------------------------------------------------------------- /notes.md: -------------------------------------------------------------------------------- 1 | # My Notes 2 | 3 | - A cmdlet is a .NET class written in C# or other language and contained in a DLL (i.e. in a binary module). 4 | - A function is specified directly in PowerShell in a script, script module or at the command line. 5 | - A module manifest may include both script and binary modules so the manifest needs to be able to export both cmdlets and functions. 6 | 7 | ## Import Module into Current Session 8 | 9 | ```powershell 10 | Import-Module "./$((Get-Item $PWD.Path).BaseName).psd1" -Verbose -Force 11 | ``` 12 | 13 | ```powershell 14 | idpdm $((Get-Item $PWD.Path).BaseName) 15 | ``` 16 | 17 | ## Generate Markdown Documentation 18 | 19 | ```powershell 20 | New-MarkdownHelp -Module "$((Get-Item $PWD.Path).BaseName)" -OutputFolder .\docs -WithModulePage 21 | 22 | Move-Item -Path "docs/$((Get-Item $PWD.Path).BaseName).md" -Destination "./README.md" 23 | 24 | (Get-ChildItem ./docs/*.md -Recurse).FullName | ForEach-Object { 25 | $text = "" 26 | $file = (Split-Path -Leaf $_ ) 27 | Get-Content $_ | ForEach-Object { 28 | $text += $_ -creplace "^online version:$", "online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/$((Get-Item $PWD.Path).BaseName)/docs/$file" 29 | $text += [System.Environment]::NewLine 30 | } 31 | 32 | Set-Content -Path $_ -Value $text 33 | Write-Output "Processed '$file'" 34 | } 35 | ``` 36 | 37 | - Update and correct each markdown file with online links and remove the extra stuff at bottom. 38 | - Add Examples. 39 | - Don't generate the external help until this is complete. 40 | 41 | ## Generate/Update Powershell Documentation 42 | 43 | ```powershell 44 | New-ExternalHelp .\docs -OutputPath en-US\ -Force 45 | ``` 46 | 47 | ## Updating the Markdown Documentation 48 | 49 | ```powershell 50 | Remove-Module "./$((Get-Item $PWD.Path).BaseName)" -Force -ErrorAction Continue 51 | Import-Module "./$((Get-Item $PWD.Path).BaseName).psd1" -Verbose -Force 52 | Update-MarkdownHelp .\docs 53 | ``` 54 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerContainerNames.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerContainerNames.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerContainerNames 9 | 10 | ## SYNOPSIS 11 | 12 | Get the container names. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-DockerContainerNames [-Running] [-Image] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-DockerContainerNames function returns the names of the Docker containers. It can also show the image name that the container is using. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-DockerContainerNames 30 | 31 | portainer_portainer_1 32 | alpine_shell 33 | debian_shell 34 | ``` 35 | 36 | This example shows the names of the current containers. 37 | 38 | ### Example 2 39 | 40 | ```powershell 41 | PS C:\> Get-DockerContainerNames -Image 42 | 43 | Name Image 44 | ---- ----- 45 | portainer_portainer_1 portainer/portainer-ce 46 | alpine_shell alpine:latest 47 | debian_shell debian:buster-slim 48 | ``` 49 | 50 | This example shows the current containers and the image that they use. 51 | 52 | ## PARAMETERS 53 | 54 | ### -Image 55 | 56 | Include the image name used for the container. 57 | 58 | ```yaml 59 | Type: SwitchParameter 60 | Parameter Sets: (All) 61 | Aliases: IncludeImage 62 | 63 | Required: False 64 | Position: Named 65 | Default value: None 66 | Accept pipeline input: False 67 | Accept wildcard characters: False 68 | ``` 69 | 70 | ### -Running 71 | 72 | Limit to only running containers. 73 | 74 | ```yaml 75 | Type: SwitchParameter 76 | Parameter Sets: (All) 77 | Aliases: 78 | 79 | Required: False 80 | Position: Named 81 | Default value: None 82 | Accept pipeline input: False 83 | Accept wildcard characters: False 84 | ``` 85 | -------------------------------------------------------------------------------- /Modules/TextFormatting/TextFormatting.psm1: -------------------------------------------------------------------------------- 1 | Function Format-XML { 2 | param ( 3 | [Parameter(Mandatory=$true, ValueFromPipeline=$true)] 4 | [ValidateNotNullOrEmpty()] 5 | [psobject] $Xml, 6 | [int] $Indent = 4, 7 | [switch] $NoNewLineOnAttribute 8 | ) 9 | 10 | BEGIN { 11 | [System.Reflection.Assembly]::LoadWithPartialName("System.Xml") | Out-Null 12 | $XmlText = "" 13 | } 14 | 15 | PROCESS { 16 | $XmlText = $XmlText + $Xml 17 | } 18 | 19 | END { 20 | $XmlText = [xml]$XmlText 21 | 22 | if (-not $XmlText ) { return } 23 | 24 | $stringWriter = New-Object System.IO.StringWriter 25 | 26 | $settings = new-object System.Xml.XmlWriterSettings 27 | $settings.Indent = $true 28 | $settings.IndentChars = " " * $Indent 29 | $settings.NewLineChars = "`r`n" 30 | if (-not ($NoNewLineOnAttribute)) { 31 | $settings.NewLineOnAttributes = $true 32 | } 33 | 34 | $settings.OmitXmlDeclaration = $false 35 | $settings.CheckCharacters = $true 36 | 37 | $settings.NamespaceHandling = [System.Xml.NamespaceHandling]::OmitDuplicates 38 | 39 | 40 | $writer = [Xml.XmlWriter]::Create($stringWriter, $settings) 41 | 42 | $XmlText.WriteContentTo($writer) 43 | 44 | $writer.Flush() 45 | $StringWriter.Flush() 46 | 47 | Write-Output $StringWriter.ToString() 48 | } 49 | } 50 | 51 | Function Format-Json { 52 | param ( 53 | [Parameter(Mandatory=$true, ValueFromPipeline=$true)] 54 | [ValidateNotNullOrEmpty()] 55 | [string] $Json 56 | ) 57 | 58 | BEGIN { 59 | $JsonText = "" 60 | } 61 | 62 | PROCESS { 63 | $JsonText = $JsonText + $Json 64 | } 65 | 66 | END { 67 | if (-not $JsonText ) { return } 68 | 69 | $JsonText | ConvertFrom-Json | ConvertTo-Json 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Modules/TeamCity/TeamCityUsers.psm1: -------------------------------------------------------------------------------- 1 | function Get-TeamCityUser { 2 | param ( 3 | [Parameter(Mandatory = $true)] 4 | [int] $Id 5 | ) 6 | 7 | $user = Invoke-TeamCityApi "users/id:$Id" 8 | 9 | $detail = New-Object PSObject 10 | $detail | Add-Member -Type NoteProperty -Name 'Id' -Value $user.id 11 | $detail | Add-Member -Type NoteProperty -Name 'UserName' -Value $user.username 12 | $detail | Add-Member -Type NoteProperty -Name 'Name' -Value $user.name 13 | 14 | $lastLogin = [DateTime]::ParseExact($user.lastLogin, 'yyyyMMddTHHmmssK', $null) 15 | 16 | $detail | Add-Member -Type NoteProperty -Name 'LastLogin' -Value $lastLogin 17 | 18 | $roles = @() 19 | 20 | foreach ($role in $user.roles.role) { 21 | $roleDetail = New-Object PSObject 22 | $roleDetail | Add-Member -Type NoteProperty -Name 'RoleId' -Value $role.roleId 23 | $roleDetail | Add-Member -Type NoteProperty -Name 'Scope' -Value $role.scope 24 | 25 | $roles += $roleDetail 26 | } 27 | 28 | $detail | Add-Member -Type NoteProperty -Name 'Roles' -Value $roles 29 | 30 | $groups = @() 31 | 32 | foreach ($group in $user.groups.group) { 33 | $groupDetail = New-Object PSObject 34 | $groupDetail | Add-Member -Type NoteProperty -Name 'Key' -Value $group.key 35 | $groupDetail | Add-Member -Type NoteProperty -Name 'Name' -Value $group.name 36 | 37 | $groups += $groupDetail 38 | } 39 | 40 | $detail | Add-Member -Type NoteProperty -Name 'Groups' -Value $groups 41 | 42 | return $detail 43 | } 44 | 45 | function Get-TeamCityUsers { 46 | $users = @() 47 | 48 | foreach ($user in (Invoke-TeamCityApi "users").user) { 49 | $detail = New-Object PSObject 50 | $detail | Add-Member -Type NoteProperty -Name 'Id' -Value $user.id 51 | $detail | Add-Member -Type NoteProperty -Name 'Name' -Value $user.name 52 | 53 | $users += $detail 54 | } 55 | 56 | return $users 57 | } 58 | -------------------------------------------------------------------------------- /Modules/VirtualBaseDisk/docs/Get-WindowsImagesInWIM.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VirtualBaseDisk-help.xml 3 | Module Name: VirtualBaseDisk 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/VirtualBaseDisk/docs/Get-WindowsImagesInWIM.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-WindowsImagesInWIM 9 | 10 | ## SYNOPSIS 11 | 12 | Gets information about all Windows images in an WIM file. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-WindowsImagesInWIM [-WimFile] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-WindowsImagesInWIM cmdlet gets a list of Windows images in a WIM file. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-WindowsImagesInWIM D:\sources\install.wim 30 | 31 | # Name 32 | - ---- 33 | 1 Windows 11 Home 34 | 2 Windows 11 Home N 35 | 3 Windows 11 Home Single Language 36 | 4 Windows 11 Education 37 | 5 Windows 11 Education N 38 | 6 Windows 11 Pro 39 | 7 Windows 11 Pro N 40 | 8 Windows 11 Pro Education 41 | 9 Windows 11 Pro Education N 42 | 10 Windows 11 Pro for Workstations 43 | 11 Windows 11 Pro N for Workstations 44 | ``` 45 | 46 | This example list the Windows Images contained in the WIM file. 47 | 48 | ## PARAMETERS 49 | 50 | ### -WimFile 51 | 52 | The WIM file is containing a file-based imaging format that are used 53 | to manage files such as drivers, updates, and components without 54 | booting the operating system image. 55 | 56 | ```yaml 57 | Type: String 58 | Parameter Sets: (All) 59 | Aliases: Path 60 | 61 | Required: True 62 | Position: 1 63 | Default value: None 64 | Accept pipeline input: False 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### CommonParameters 69 | 70 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 71 | -------------------------------------------------------------------------------- /Modules/ElasticSearch/ElasticSearchIndex.psm1: -------------------------------------------------------------------------------- 1 | function Get-ElasticSearchIndex { 2 | param ( 3 | [Alias("Name")] 4 | [string] $IndexName 5 | ) 6 | 7 | if ($IndexName) { 8 | (Invoke-ElasticSearchApi "$IndexName").$IndexName 9 | } else { 10 | Invoke-ElasticSearchApi "_cat/indices" 11 | } 12 | } 13 | 14 | function Get-ElasticSearchIndexDocumentCount { 15 | param ( 16 | [string] $Filter, 17 | [switch] $Not 18 | ) 19 | 20 | $indexes = Get-ElasticSearchIndex | Select-Object index, health, 'docs.count', 'store.size' 21 | 22 | if ($Filter) { 23 | if ($Not) { 24 | $indexes = $indexes | Where-Object { $_.index -notlike "*$Filter*" } 25 | } else { 26 | $indexes = $indexes | Where-Object { $_.index -like "*$Filter*" } 27 | } 28 | } 29 | 30 | $indexes = $indexes | Sort-Object index 31 | 32 | return $indexes 33 | } 34 | 35 | function New-ElasticSearchIndex { 36 | # (PUT) 37 | 38 | # Settings 39 | # Mappings 40 | # Aliases 41 | } 42 | 43 | function Remove-ElasticSearchIndex { 44 | [CmdletBinding()] 45 | param ( 46 | [Parameter(Mandatory = $true)] 47 | [string] $IndexPattern 48 | ) 49 | 50 | Invoke-ElasticSearchApi -Method "$IndexPattern" -HttpMethod DELETE 51 | } 52 | 53 | function Test-ElasticSearchIndex { 54 | param ( 55 | [Parameter(Mandatory = $true)] 56 | [Alias("Name")] 57 | [string] $IndexName 58 | ) 59 | 60 | Use-ElasticSearchProfile 61 | 62 | $uri = "$env:ElasticSearchUrl/$IndexName" 63 | 64 | try { 65 | $response = (Invoke-WebRequest -Uri $uri -Method "HEAD").StatusCode 66 | } catch { 67 | $response = $_.Exception.Response.StatusCode.Value__ 68 | } 69 | 70 | if ($response -eq 200) { 71 | return $true 72 | } 73 | 74 | return $false 75 | } 76 | 77 | function Update-ElastSearchIndex { 78 | # (PUT???) 79 | } 80 | -------------------------------------------------------------------------------- /Modules/SqlServer/SqlServer.psm1: -------------------------------------------------------------------------------- 1 | function Find-SqlCmd { 2 | return Find-FirstPath ` 3 | (Find-ProgramFiles 'Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\sqlcmd.exe') ` 4 | (Find-ProgramFiles 'Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\sqlcmd.exe') ` 5 | (Find-ProgramFiles 'Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe') ` 6 | "$pwd\sqlcmd.exe" 7 | } 8 | 9 | function Invoke-SqlCmd { 10 | cmd /c """$(Find-SqlCmd)"" $args" 11 | } 12 | 13 | function Invoke-SqlFile { 14 | param ( 15 | [Parameter(Mandatory=$true)] 16 | [ValidateNotNullOrEmpty()] 17 | [ValidateScript({ Test-Path $(Resolve-Path $_) })] 18 | [string]$Path, 19 | [string] $SqlServer 20 | ) 21 | 22 | if ($SqlServer) { 23 | $env:SQLCMDSERVER = $SqlServer 24 | } 25 | 26 | $sqlFile = "${env:TEMP}\$((New-Guid).Guid).sql" 27 | 28 | Set-Content -Path $sqlFile -Value @" 29 | BEGIN TRANSACTION SQLCMDT1 30 | 31 | PRINT '--- Execution Starting ---' 32 | PRINT ' $SqlFile' 33 | 34 | GO 35 | 36 | $(Get-Content -Path $Path -Raw) 37 | 38 | GO 39 | 40 | PRINT '--- Execution Finished ---' 41 | IF (@@ERROR <> 0) 42 | BEGIN 43 | PRINT 'Error Occurred, rolling transaction back' 44 | ROLLBACK TRANSACTION SQLCMDT1 45 | END 46 | ELSE 47 | COMMIT TRANSACTION SQLCMDT1 48 | 49 | GO 50 | "@ 51 | 52 | Invoke-SqlCmd -i $sqlFile -r 1 -b 53 | } 54 | 55 | function Register-SqlCmdSqlCredentials { 56 | param ( 57 | [pscredential] $Credentials = $(Get-Credential -Message "Enter SQL Credentials...") 58 | ) 59 | 60 | $env:SQLCMDUSER = $Credentials.UserName 61 | $env:SQLCMDPASSWORD = $Credentials.GetNetworkCredential().password 62 | } 63 | 64 | function Start-MSSqlServer { 65 | & sc.exe start MSSQLSERVER 66 | } 67 | 68 | Set-Alias -Name mssql-start -Value Start-MSSqlServer 69 | 70 | function Stop-MSSqlServer { 71 | & sc.exe stop MSSQLSERVER 72 | } 73 | 74 | Set-Alias -Name mssql-stop -Value Stop-MSSqlServer 75 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Pop-DockerImage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Pop-DockerImage.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Pop-DockerImage 9 | 10 | ## SYNOPSIS 11 | 12 | Pull an Docker image from a registry. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Pop-DockerImage [-Name] [[-Tag] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Pop-DockerImage function is a basic wrapper around the docker pull command but allows the Name and Tag to be separate parmeters. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Pop-DockerImage -Name "ubuntu" -Tag "22.04" 30 | 31 | 22.04: Pulling from library/ubuntu 32 | 25f4cd1d54a5: Pull complete 33 | Digest: sha256:0ad36748089181d832164977bdeb56d08672e352173127d8bfcd9aa4f7b3bd41 34 | Status: Downloaded newer image for ubuntu:22.04 35 | docker.io/library/ubuntu:22.04 36 | ``` 37 | 38 | This example pulls the ubuntu image with the 22.04 tag. 39 | 40 | ## PARAMETERS 41 | 42 | ### -Name 43 | 44 | Specify the name of the Docker image. 45 | 46 | ```yaml 47 | Type: String 48 | Parameter Sets: (All) 49 | Aliases: 50 | 51 | Required: True 52 | Position: 0 53 | Default value: None 54 | Accept pipeline input: False 55 | Accept wildcard characters: False 56 | ``` 57 | 58 | ### -Tag 59 | 60 | Specify the tag of the Docker image. 61 | 62 | ```yaml 63 | Type: String 64 | Parameter Sets: (All) 65 | Aliases: 66 | 67 | Required: False 68 | Position: 1 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### CommonParameters 75 | 76 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 77 | -------------------------------------------------------------------------------- /Modules/VirtualDevelopment/docs/New-DevVM.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VirtualDevelopment-help.xml 3 | Module Name: VirtualDevelopment 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/VirtualDevelopment/docs/New-DevVM.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-DevVM 9 | 10 | ## SYNOPSIS 11 | 12 | Create a Development VM. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | New-DevVM 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The New-DevVM cmdlet creates a VM based on the Host machine's name using the latest Windows Insiders base disk. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> New-DevVM 30 | 31 | Creating a Differencing Disk [HOSTMACHINEDEV.vhdx] based on [C:\Virtual Machines\BaseVHDX\Win11BaseInsider-10.0.22533.vhdx] 32 | 33 | ComputerName : HOSTMACHINE 34 | Path : C:\Virtual Machines\Discs\HOSTMACHINEDEV.vhdx 35 | VhdFormat : VHDX 36 | VhdType : Differencing 37 | FileSize : 4194304 38 | Size : 107374182400 39 | MinimumSize : 107373150720 40 | LogicalSectorSize : 512 41 | PhysicalSectorSize : 4096 42 | BlockSize : 2097152 43 | ParentPath : C:\Virtual Machines\BaseVHDX\Win11BaseInsider-10.0.22533.vhdx 44 | DiskIdentifier : B87479B3-E57C-4029-BE23-F9CD995E325B 45 | FragmentationPercentage : 46 | Alignment : 1 47 | Attached : False 48 | DiskNumber : 49 | IsPMEMCompatible : False 50 | AddressAbstractionType : None 51 | Number : 52 | 53 | Creating HOSTMACHINEDEV VM... 54 | 55 | Name : HOSTMACHINEDEV 56 | State : Off 57 | CpuUsage : 0 58 | MemoryAssigned : 0 59 | MemoryDemand : 0 60 | MemoryStatus : 61 | Uptime : 00:00:00 62 | Status : Operating normally 63 | ReplicationState : Disabled 64 | Generation : 2 65 | ``` 66 | 67 | This example creates the Development VM based on the host computer's name. 68 | 69 | ## PARAMETERS 70 | 71 | ### None 72 | -------------------------------------------------------------------------------- /Modules/TeamCity/TeamCity.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2020.6.7.1' 3 | GUID = '30e20011-16a8-4280-a894-12814809ff25' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'TeamCity.psm1' 7 | NestedModules = @( 8 | "TeamCityAgents.psm1" 9 | "TeamCityBuilds.psm1" 10 | "TeamCityProjects.psm1" 11 | "TeamCityUsers.psm1" 12 | ) 13 | TypesToProcess = @() 14 | FormatsToProcess = @() 15 | FunctionsToExport = @( 16 | "Approve-TeamCityAgent" 17 | "Clear-TeamCityProfile" 18 | "Deny-TeamCityAgent" 19 | "Disable-TeamCityAgent" 20 | "Enable-TeamCityAgent" 21 | "Get-TeamCityAgent" 22 | "Get-TeamCityAgentPool" 23 | "Get-TeamCityAgentPools" 24 | "Get-TeamCityAgents" 25 | "Get-TeamCityBackup" 26 | "Get-TeamCityBuild" 27 | "Get-TeamCityBuilds" 28 | "Get-TeamCityBuildConfiguration" 29 | "Get-TeamCityBuildConfigurations" 30 | "Get-TeamCityBuildQueue" 31 | "Get-TeamCityBuildQueueDetail" 32 | "Get-TeamCityBuildStatistics" 33 | "Get-TeamCityBuildTests" 34 | "Get-TeamCityProject" 35 | "Get-TeamCityProjects" 36 | "Get-TeamCityServerLicense" 37 | "Get-TeamCityServerUptime" 38 | "Get-TeamCityServerVersion" 39 | "Get-TeamCityUser" 40 | "Get-TeamCityUsers" 41 | "Import-TeamCityProfile" 42 | "Invoke-TeamCityApi" 43 | "Invoke-TeamCityBackup" 44 | "Move-TeamCityAgent" 45 | "Set-TeamCityProfile" 46 | "Start-TeamCityBuild" 47 | "Stop-TeamCityBuild" 48 | "Test-TeamCityProfile" 49 | "Use-TeamCityProfile" 50 | ) 51 | AliasesToExport = @( 52 | "Authorize-TeamCityAgent" 53 | "Backup-TeamCity" 54 | "Load-TeamCityProfile" 55 | "teamcityapi" 56 | "teamcity-api" 57 | "teamcity-profile-clear" 58 | "teamcity-profile-load" 59 | "Unauthorize-TeamCityAgent" 60 | ) 61 | } 62 | -------------------------------------------------------------------------------- /choco/dcjulian29.psmodules/build.ps1: -------------------------------------------------------------------------------- 1 | trap [System.Exception] { 2 | "Exception: {0}" -f $_.Exception.Message 3 | [Environment]::Exit(1) 4 | } 5 | 6 | $ErrorActionPreference = "Stop" 7 | $baseDir = (Resolve-Path $(Split-Path -Parent (Split-Path -Parent $PSScriptRoot))).Path 8 | $toolDir = Join-Path -Path $baseDir -ChildPath ".tools" 9 | 10 | if (Get-Command -Name "nuget" -ErrorAction SilentlyContinue) { 11 | $nuget = (Get-Command -Name "nuget").Source 12 | } else { 13 | $nuget = Join-Path -Path $toolDir -ChildPath "nuget.exe" 14 | 15 | if (-not (Test-Path -Path $nuget)) { 16 | if (-not (Test-Path $toolDir)) { 17 | New-Item -Path $toolDir -Type Directory | Out-Null 18 | } 19 | 20 | Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ` 21 | -OutFile $nuget 22 | } 23 | } 24 | 25 | $packDir = Join-Path -Path $baseDir -ChildPath ".meta" 26 | 27 | if (-not (Test-Path $packDir)) { 28 | New-Item -Path $packDir -ItemType Directory | Out-Null 29 | } 30 | 31 | $nuspec = Join-Path -Path $PSScriptRoot -ChildPath chocolateyPackage.nuspec 32 | 33 | #------------------------------------------------------------------------------ 34 | 35 | $project = "dcjulian29.psmodules" 36 | $major = Get-Date -Format "yyMM" 37 | $minor = (Get-Date).Day 38 | $patch = 1 39 | $baseUrl = "https://www.myget.org/F/dcjulian29-chocolatey/api/v2/package" 40 | $version = "" 41 | 42 | while ($version.Length -eq 0) { 43 | try { 44 | Invoke-RestMethod ` 45 | -Uri "$baseUrl/$project/$major.$minor.$patch" ` 46 | -Method Head 47 | 48 | $patch++ 49 | } catch { 50 | $version = "$major.$minor.$patch" 51 | } 52 | } 53 | 54 | #------------------------------------------------------------------------------ 55 | 56 | $al = @( 57 | "pack" 58 | "$nuspec" 59 | "-OutputDirectory $packDir" 60 | "-Verbosity detailed" 61 | "-NoPackageAnalysis" 62 | "-NonInteractive" 63 | "-NoDefaultExcludes" 64 | "-Version $version" 65 | ) 66 | 67 | Start-Process -FilePath $nuget -ArgumentList $al -NoNewWindow -Wait 68 | -------------------------------------------------------------------------------- /Modules/AzureDevOps/AzureDevOps.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2020.7.24.1' 3 | GUID = '563f363a-2b2d-4ae5-b7f0-eddaf6087ca4' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'AzureDevOps.psm1' 7 | NestedModules = @( 8 | "AzureDevOpsGit.psm1" 9 | "AzureDevOpsProjects.psm1" 10 | "AzureDevOpsRepository.psm1" 11 | "AzureDevOpsWorkItems.psm1" 12 | ) 13 | TypesToProcess = @() 14 | FormatsToProcess = @() 15 | FunctionsToExport = @( 16 | "Add-AdoWorkItemComment" 17 | "Clear-AzureDevOpsDefaultProject" 18 | "Clear-AzureDevOpsProfile" 19 | "Get-AdoProcessTemplate" 20 | "Get-AdoProcessTemplates" 21 | "Get-AdoProject" 22 | "Get-AdoProjectProperties" 23 | "Get-AdoProjects" 24 | "Get-AdoRepository" 25 | "Get-AdoWorkItem" 26 | "Get-AzureDevOpsDefaultProject" 27 | "Get-AzureDevOpsGitCommit" 28 | "Get-AzureDevOpsProfile" 29 | "Get-AzureDevOpsProjectProcess" 30 | "Get-AzureDevOpsRepository" 31 | "Import-AzureDevOpsProfile" 32 | "Invoke-AzureDevOpsApi" 33 | "Join-AdoWorkItem" 34 | "Join-AdoWorkItemAsChild" 35 | "Join-AdoWorkItemAsParent" 36 | "New-AdoBug" 37 | "New-AdoIssue" 38 | "New-AdoProject" 39 | "New-AdoTask" 40 | "New-AdoWorkItem" 41 | "New-AdoUserStory" 42 | "Set-AzureDevOpsDefaultProject" 43 | "Set-AzureDevOpsProfile" 44 | "Set-AdoWorkItemState" 45 | "Test-AzureDevOpsDefaultProject" 46 | "Test-AzureDevOpsProfile" 47 | "Use-AzureDevOpsProfile" 48 | ) 49 | AliasesToExport = @( 50 | "adoapi" 51 | "ado-bug" 52 | "ado-comment" 53 | "ado-issue" 54 | "ado-profile-clear" 55 | "ado-profile-load" 56 | "ado-task" 57 | "ado-userstory" 58 | "azuredevops-api" 59 | "azuredevops-profile-clear" 60 | "azuredevops-profile-load" 61 | "Load-AzureDevOpsProfile" 62 | ) 63 | } 64 | -------------------------------------------------------------------------------- /Modules/OctopusDeploy/OctopusDeploy.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '2020.5.11.1' 3 | GUID = 'b3764581-214b-4403-b277-e97b6ad00c51' 4 | Author = 'Julian Easterling' 5 | PowerShellVersion = '3.0' 6 | RootModule = 'OctopusDeploy.psm1' 7 | NestedModules = @( 8 | "OctopusDeployments.psm1" 9 | "OctopusEnvironments.psm1" 10 | "OctopusProjects.psm1" 11 | "OctopusReleases.psm1" 12 | "OctopusServer.psm1" 13 | ) 14 | TypesToProcess = @() 15 | FormatsToProcess = @() 16 | FunctionsToExport = @( 17 | "Clear-OctopusProfile" 18 | "Find-Octo" 19 | "Get-OctopusDeploymentsForEnvironment" 20 | "Get-OctopusEnvironment" 21 | "Get-OctopusEnvironments" 22 | "Get-OctopusLastDeploymentsForEnvironment" 23 | "Get-OctopusProject" 24 | "Get-OctopusProjectById" 25 | "Get-OctopusProjects" 26 | "Get-OctopusRelease" 27 | "Get-OctopusReleaseById" 28 | "Get-OctopusReleases" 29 | "Get-OctopusReleasesForEnvironment" 30 | "Get-OctopusReleasesForProjectInEnvironment" 31 | "Get-OctopusServerUptime" 32 | "Get-OctopusServerVersion" 33 | "Import-OctopusProfile" 34 | "Invoke-DeployOctopusRelease" 35 | "Invoke-Octo" 36 | "Invoke-OctopusApi" 37 | "New-OctopusPackage" 38 | "New-OctopusRelease" 39 | "Push-OctopusPackage" 40 | "Set-OctopusProfile" 41 | "Test-OctopusProfile" 42 | "Use-OctopusProfile" 43 | ) 44 | AliasesToExport = @( 45 | "Create-OctopusRelease" 46 | "Load-OctoputProfile" 47 | "octo" 48 | "octoapi" 49 | "octo-profile-clear" 50 | "octo-profile-load" 51 | "octo-publish" 52 | "octo-release-create" 53 | "octo-release-deploy" 54 | "octopus" 55 | "octopusapi" 56 | "octopus-api" 57 | "octopus-profile-clear" 58 | "octopus-profile-load" 59 | "octopus-publish" 60 | "octopus-release-create" 61 | "octopus-release-deploy" 62 | ) 63 | } 64 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerMountPoint.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerMountPoint.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerMountPoint 9 | 10 | ## SYNOPSIS 11 | 12 | Convert a path to a mountpoint that Docker can use. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-DockerMountPoint [-Path] [-UnixStyle] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-DockerMountPoint function coverts a relative or absolute folder/file path to a format that Docker can use to bind mount volumes. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-DockerMountPoint $env:TEMP 30 | 31 | C:/Users/julian/AppData/Local/Temp 32 | ``` 33 | 34 | This example shows a Windows-style mount point for Docker. 35 | 36 | ### Example 2 37 | 38 | ```powershell 39 | PS C:\> Get-DockerMountPoint $env:TEMP -UnixStyle 40 | 41 | /mnt/c/Users/julian/AppData/Local/Temp 42 | ``` 43 | 44 | This example shows a UNIX-style mount point for Docker. 45 | 46 | ## PARAMETERS 47 | 48 | ### -Path 49 | 50 | Specify a path to a file or folder. 51 | 52 | ```yaml 53 | Type: String 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: 0 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -UnixStyle 65 | 66 | Specify to return the path as a UNIX style. 67 | 68 | ```yaml 69 | Type: SwitchParameter 70 | Parameter Sets: (All) 71 | Aliases: 72 | 73 | Required: False 74 | Position: Named 75 | Default value: None 76 | Accept pipeline input: False 77 | Accept wildcard characters: False 78 | ``` 79 | 80 | ### CommonParameters 81 | 82 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 83 | -------------------------------------------------------------------------------- /Modules/Networking/PacketCapture.psm1: -------------------------------------------------------------------------------- 1 | function pm { 2 | Start-Process -FilePath "$env:WinDir\System32\PktMon.exe" ` 3 | -ArgumentList $args -NoNewWindow -Wait 4 | } 5 | 6 | #------------------------------------------------------------------------------ 7 | 8 | function Add-PacketFilter { 9 | param ( 10 | [string] $Name, 11 | [int] $Port, 12 | [ValidateSet("IPv4", "IPv6", "ARP")] 13 | [string] $Protocol, 14 | [ValidateSet("TCP", "UDP", "ICMP", "ICMPv6")] 15 | [string] $ProtocolType, 16 | [string] $IpAddress 17 | ) 18 | 19 | $parameter = "filter add" 20 | 21 | if ($Name) { 22 | $parameter = "$parameter $Name" 23 | } 24 | 25 | if ($Protocol) { 26 | $parameter = "$parameter -d $Protocol" 27 | } 28 | 29 | if ($ProtocolType) { 30 | $parameter = "$parameter -t $ProtocolType" 31 | } 32 | 33 | if ($IpAddress) { 34 | $parameter = "$parameter -i $IPAddress" 35 | } 36 | 37 | if ($Port) { 38 | $parameter = "$parameter -p $Port" 39 | } 40 | 41 | pm $parameter 42 | } 43 | 44 | function Clear-PacketFilter { 45 | pm filter remove 46 | } 47 | 48 | function Convert-PacketCaptureFile { 49 | param ( 50 | [ValidateScript({ Test-Path $(Resolve-Path $_) })] 51 | [string] $Path = "PktMon.etl", 52 | [switch] $TextFormat 53 | ) 54 | 55 | $info = Get-Item $(Resolve-Path $Path) 56 | $file = Join-Path $info.Directory $info.BaseName 57 | $pcap = & "$env:WinDir\System32\PktMon.exe" pcapng help 2> $null 58 | 59 | if ($TextFormat -or (-not $pcap)) { 60 | pm format "$info" -o "$file.txt" 61 | } else { 62 | pm pcapng "$info" -o "$file.pcap" 63 | } 64 | } 65 | 66 | function Get-PacketFilter { 67 | pm filter list 68 | } 69 | 70 | function Start-PacketCapture { 71 | param ( 72 | [string] $Path = "PktMon.etl", 73 | [long] $Size = 1GB 74 | ) 75 | 76 | pm start --etw -p 0 -f $Path -s ($Size / 1MB) 77 | } 78 | 79 | function Stop-PacketCapture { 80 | pm stop 81 | } 82 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Start-DockerContainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Start-DockerContainer.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Start-DockerContainer 9 | 10 | ## SYNOPSIS 11 | 12 | Start one or more stopped containers. 13 | 14 | ## SYNTAX 15 | 16 | ### ID (Default) 17 | 18 | ```powershell 19 | Start-DockerContainer [-Id] [] 20 | ``` 21 | 22 | ### All 23 | 24 | ```powershell 25 | Start-DockerContainer [-All] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | The Start-DockerContainer functions starts one or more stopped containers. 31 | 32 | ## EXAMPLES 33 | 34 | ### Example 1 35 | 36 | ```powershell 37 | PS C:\> Start-DockerContainer 6abce5607 38 | 6abce5607 39 | ``` 40 | 41 | This example starts the specified container. 42 | 43 | ### Example 2 44 | 45 | ```powershell 46 | PS C:\> Stop-DockerContainer -All 47 | ca0405e0daf8 48 | 20e11a17233e 49 | 31bdb168cafd 50 | ``` 51 | 52 | This example starts all stopped containers. 53 | 54 | ## PARAMETERS 55 | 56 | ### -All 57 | 58 | Specify to start all stopped containers. 59 | 60 | ```yaml 61 | Type: SwitchParameter 62 | Parameter Sets: All 63 | Aliases: 64 | 65 | Required: False 66 | Position: Named 67 | Default value: None 68 | Accept pipeline input: False 69 | Accept wildcard characters: False 70 | ``` 71 | 72 | ### -Id 73 | 74 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 75 | 76 | ```yaml 77 | Type: String 78 | Parameter Sets: (All) 79 | Aliases: 80 | 81 | Required: True 82 | Position: 0 83 | Default value: None 84 | Accept pipeline input: False 85 | Accept wildcard characters: False 86 | ``` 87 | 88 | ### CommonParameters 89 | 90 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 91 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Remove-DockerImage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Remove-DockerImage.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-DockerImage 9 | 10 | ## SYNOPSIS 11 | 12 | Remove one or more Docker images. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Remove-DockerImage [[-Id] ] [[-Name] ] [-Unused] [-Force] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Remove-DockerImage removes one or more Docker images. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Remove-DockerImage -Id 8ed4840f8ea533b6b4ada 30 | 31 | Deleted: sha256:8ed4840f8ea533b6b4ada6c19eb6bed0c0762ab8c11e3e312a266a987d1fc48b 32 | ``` 33 | 34 | This example deletes the specified image. 35 | 36 | ## PARAMETERS 37 | 38 | ### -Force 39 | 40 | Force removal of the image. 41 | 42 | ```yaml 43 | Type: SwitchParameter 44 | Parameter Sets: (All) 45 | Aliases: 46 | 47 | Required: False 48 | Position: Named 49 | Default value: None 50 | Accept pipeline input: False 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### -Id 55 | 56 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 57 | 58 | ```yaml 59 | Type: String 60 | Parameter Sets: (All) 61 | Aliases: 62 | 63 | Required: False 64 | Position: 0 65 | Default value: None 66 | Accept pipeline input: False 67 | Accept wildcard characters: False 68 | ``` 69 | 70 | ### -Name 71 | 72 | The name of the image. 73 | 74 | ```yaml 75 | Type: String 76 | Parameter Sets: (All) 77 | Aliases: 78 | 79 | Required: False 80 | Position: 1 81 | Default value: None 82 | Accept pipeline input: False 83 | Accept wildcard characters: False 84 | ``` 85 | 86 | ### -Unused 87 | 88 | Specifies to remove unused images. 89 | 90 | ```yaml 91 | Type: SwitchParameter 92 | Parameter Sets: (All) 93 | Aliases: 94 | 95 | Required: False 96 | Position: Named 97 | Default value: None 98 | Accept pipeline input: False 99 | Accept wildcard characters: False 100 | ``` 101 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Invoke-DockerLog.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Invoke-DockerLog.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-DockerLog 9 | 10 | ## SYNOPSIS 11 | 12 | Get a container's logs. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Invoke-DockerLog [-Id] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Invoke-DockerLog function retrieves the logs for the specified container. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Invoke-DockerLog -Id 9a66ed0f 30 | 31 | 2022/01/29 15:01:53 server: Reverse tunnelling enabled 32 | 2022/01/29 15:01:53 server: Fingerprint 5e:ea:82:36:f1:bc:63:3a:8e:d9:0b:10:c4:22:2e:1e 33 | 2022/01/29 15:01:53 server: Listening on 0.0.0.0:8000... 34 | level=info msg="2022/01/29 15:01:53 [INFO] [cmd,main] Starting Portainer version 2.11.0" 35 | level=info msg="2022/01/29 15:01:53 [DEBUG] [chisel, monitoring] [check_interval_seconds: 10.000000] [message: starting tunnel management process]" 36 | level=info msg="2022/01/29 15:01:53 [DEBUG] [internal,init] [message: start initialization monitor ]" 37 | level=info msg="2022/01/29 15:01:53 [INFO] [http,server] [message: starting HTTPS server on port :9443]" 38 | level=info msg="2022/01/29 15:01:53 [INFO] [http,server] [message: starting HTTP server on port :9000]" 39 | ``` 40 | 41 | This example shows the log of a running Portainer container. 42 | 43 | ## PARAMETERS 44 | 45 | ### -Id 46 | 47 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 48 | 49 | ```yaml 50 | Type: String 51 | Parameter Sets: (All) 52 | Aliases: 53 | 54 | Required: True 55 | Position: 0 56 | Default value: None 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | 61 | ### CommonParameters 62 | 63 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 64 | -------------------------------------------------------------------------------- /Modules/PowershellForAnsible/README.md: -------------------------------------------------------------------------------- 1 | 2 | # PowershellForAnsible ![Version](https://img.shields.io/myget/dcjulian29-powershell/v/PowershellForAnsible) 3 | 4 | Provides functions to interact with an Ansible control node via Docker for Desktop on a Windows host system. From a Powershell prompt and assuming the current directory contains all "Ansible" files, a user of this module should be able to use Ansible as if it were running natively on the Windows host system. 5 | 6 | ## Functions 7 | 8 | - [Confirm-AnsiblePlaybookSyntax](docs/Confirm-AnsiblePlaybookSyntax.md) 9 | - [Edit-AnsibleVault](docs/Edit-AnsibleVault.md) 10 | - [Export-AnsibleFacts](docs/Export-AnsibleFacts.md) 11 | - [Get-AnsibleConfig](docs/Get-AnsibleConfig.md) 12 | - [Get-AnsibleConfigDump](docs/Get-AnsibleConfigDump.md) 13 | - [Get-AnsibleConfigFile](docs/Get-AnsibleConfigFile.md) 14 | - [Get-AnsibleFacts](docs/Get-AnsibleFacts.md) 15 | - [Get-AnsibleHostVariables](docs/Get-AnsibleHostVariables.md) 16 | - [Get-AnsibleInventoryAsJson](docs/Get-AnsibleInventoryAsJson.md) 17 | - [Get-AnsibleInventoryAsToml](docs/Get-AnsibleInventoryAsToml.md) 18 | - [Get-AnsibleInventoryAsYaml](docs/Get-AnsibleInventoryAsYaml.md) 19 | - [Get-AnsibleInventoryGraph](docs/Get-AnsibleInventoryGraph.md) 20 | - [Get-AnsibleLintRules](docs/Get-AnsibleLintRules.md) 21 | - [Get-AnsibleLintTags](docs/Get-AnsibleLintTags.md) 22 | - [Get-AnsiblePlaybookHosts](docs/Get-AnsiblePlaybookHosts.md) 23 | - [Get-AnsiblePlaybookTags](docs/Get-AnsiblePlaybookTags.md) 24 | - [Get-AnsiblePlaybookTasks](docs/Get-AnsiblePlaybookTasks.md) 25 | - [Get-AnsibleVariables](docs/Get-AnsibleVariables.md) 26 | - [Invoke-AnsibleContainer](docs/Invoke-AnsibleContainer.md) 27 | - [Invoke-AnsibleHostCommand](docs/Invoke-AnsibleHostCommand.md) 28 | - [Invoke-AnsibleLintPlaybook](docs/Invoke-AnsibleLintPlaybook.md) 29 | - [Invoke-AnsibleLintRole](docs/Invoke-AnsibleLintRole.md) 30 | - [Ping-AnsibleHost](docs/Ping-AnsibleHost.md) 31 | - [Protect-AnsibleVariable](docs/Protect-AnsibleVariable.md) 32 | - [Show-AnsibleFacts](docs/Show-AnsibleFacts.md) 33 | - [Show-AnsibleVariables](docs/Show-AnsibleVariables.md) 34 | - [Show-AnsibleVault](docs/Show-AnsibleVault.md) 35 | - [Test-AnsiblePlaybookSyntax](docs/Test-AnsiblePlaybookSyntax.md) 36 | - [Test-AnsibleProvision](docs/Test-AnsibleProvision.md) 37 | - [Update-AnsibleHost](docs/Update-AnsibleHost.md) 38 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Disconnect-DockerNetwork.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Disconnect-DockerNetwork.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Disconnect-DockerNetwork 9 | 10 | ## SYNOPSIS 11 | 12 | Disconnect a container to a network. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Disconnect-DockerNetwork [-NetworkName] [-ContainerName] [-Force] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Disconnect-DockerNetwork function disconnect the specified docker-based network for the specified container. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Disconnect-DockerNetwork -NetworkName "testnet" -ContainerName "c760a7b628ba" 30 | 31 | ``` 32 | 33 | This example disconnects the testnet network from the identified container. 34 | 35 | ## PARAMETERS 36 | 37 | ### -ContainerName 38 | 39 | Specifies the UUID identifier or container name that the Docker daemon uses to identify the container. 40 | 41 | ```yaml 42 | Type: String 43 | Parameter Sets: (All) 44 | Aliases: 45 | 46 | Required: True 47 | Position: 1 48 | Default value: None 49 | Accept pipeline input: False 50 | Accept wildcard characters: False 51 | ``` 52 | 53 | ### -Force 54 | 55 | Instruct Docker to force the removal of the network. 56 | 57 | ```yaml 58 | Type: SwitchParameter 59 | Parameter Sets: (All) 60 | Aliases: 61 | 62 | Required: False 63 | Position: Named 64 | Default value: None 65 | Accept pipeline input: False 66 | Accept wildcard characters: False 67 | ``` 68 | 69 | ### -NetworkName 70 | 71 | Specifies the name of the docker-based network to disconnect from. 72 | 73 | ```yaml 74 | Type: String 75 | Parameter Sets: (All) 76 | Aliases: 77 | 78 | Required: True 79 | Position: 0 80 | Default value: None 81 | Accept pipeline input: False 82 | Accept wildcard characters: False 83 | ``` 84 | 85 | ### CommonParameters 86 | 87 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 88 | -------------------------------------------------------------------------------- /Modules/AzureDevOps/AzureDevOpsProjects.psm1: -------------------------------------------------------------------------------- 1 | function Get-AdoProcessTemplate { 2 | [CmdletBinding()] 3 | param ( 4 | [Parameter(Mandatory = $true)] 5 | [string] $Id 6 | ) 7 | 8 | Invoke-AzureDevOpsApi "process/processes/$Id" 9 | } 10 | 11 | function Get-AdoProcessTemplates { 12 | (Invoke-AzureDevOpsApi "process/processes").value 13 | } 14 | 15 | function Get-AzureDevOpsProjectProcess { 16 | [CmdletBinding()] 17 | param ( 18 | [string] $Id 19 | ) 20 | 21 | if (-not $Id) { 22 | if (Test-AzureDevOpsDefaultProject) { 23 | $name = $env:AzureDevOpsProject 24 | $Id = (Get-AdoProjects | Where-Object { $_.name -eq $name }).id 25 | 26 | } else { 27 | throw "Azure DevOps project was not provided and a default one is not set!" 28 | } 29 | } 30 | 31 | (Get-AdoProjectProperties $Id | Where-Object { $_.name -eq 'System.Process Template' }).value 32 | } 33 | 34 | function Get-AdoProject { 35 | [CmdletBinding()] 36 | param ( 37 | [Parameter(Mandatory = $true)] 38 | [string] $Id 39 | ) 40 | 41 | Invoke-AzureDevOpsApi "projects/$Id" 42 | } 43 | 44 | function Get-AdoProjectProperties { 45 | [CmdletBinding()] 46 | param ( 47 | [Parameter(Mandatory = $true)] 48 | [string] $Id 49 | ) 50 | 51 | (Invoke-AzureDevOpsApi "projects/$Id/properties" -Version "5.1-preview.1").value 52 | } 53 | 54 | function Get-AdoProjects { 55 | (Invoke-AzureDevOpsApi "projects/$Id").value 56 | } 57 | 58 | function New-AdoProject { 59 | [CmdletBinding()] 60 | param ( 61 | [Parameter(Mandatory = $true)] 62 | [string] $Name, 63 | [Parameter(Mandatory = $true)] 64 | [string] $ProcessId, 65 | [string] $Description 66 | ) 67 | 68 | $configuration = @{ 69 | "name" = "$Name" 70 | "description" = "$Description" 71 | "ProjectVisibility" = "private" 72 | "capabilities" = @{ 73 | "versioncontrol" = @{ 74 | "sourceControlType" = "Git" 75 | } 76 | "processTemplate" = @{ 77 | "templateTypeId" = "$ProcessId" 78 | } 79 | } 80 | } | ConvertTo-Json -Depth 5 81 | 82 | Invoke-AzureDevOpsApi "projects" -HttpMethod "POST" -Body $configuration 83 | } 84 | -------------------------------------------------------------------------------- /Modules/PowershellForGit/GitCommits.psm1: -------------------------------------------------------------------------------- 1 | function Get-LastGitCommit { 2 | [CmdletBinding(DefaultParameterSetName="Id")] 3 | param ( 4 | [Parameter(ParameterSetName="Id")] 5 | [Switch]$Id, 6 | [Parameter(ParameterSetName="Author")] 7 | [Switch]$Author, 8 | [Parameter(ParameterSetName="Author")] 9 | [Switch]$Email, 10 | [Parameter(ParameterSetName="Date")] 11 | [Switch]$Date, 12 | [Parameter(ParameterSetName="DateTime")] 13 | [Switch]$DateTime 14 | ) 15 | 16 | $parameters = "--no-pager log --max-count=1" 17 | 18 | if ($DateTime) { 19 | $parameters += " --pretty=format:""%aD""" 20 | 21 | Get-Date $(cmd /c """$(Find-Git)"" $parameters") 22 | } else { 23 | if ($Id) { 24 | $parameters = "rev-parse $(Get-GitRepositoryBranch)" 25 | } 26 | 27 | if ($Author) { 28 | $parameters += " --pretty=format:""%an""" 29 | } 30 | 31 | if ($Email) { 32 | $parameters += " --pretty=format:""%ae""" 33 | } 34 | 35 | if ($Author -and $Email) { 36 | $parameters += " --pretty=format:""%an <%ae>""" 37 | } 38 | 39 | if ($Date) { 40 | $parameters += " --pretty=format:""%ad""" 41 | } 42 | 43 | cmd /c """$(Find-Git)"" $parameters" 44 | } 45 | } 46 | 47 | function Get-LastGitTag { 48 | param ( 49 | [string] $Filter = "" 50 | ) 51 | 52 | $tags = cmd /c """$(Find-Git)"" log --tags --simplify-by-decoration --pretty=format:""%d""" 53 | 54 | $tags = $tags -like "*tag:*$filter*" 55 | 56 | return [regex]::Match($tags[0], '^\s\(tag:\s([^,)]+).*$').Groups[1].Value 57 | } 58 | 59 | function Remove-AllGitChanges { 60 | & "$(Find-Git)" reset HEAD 61 | & "$(Find-Git)" stash save --keep-index 62 | & "$(Find-Git)" stash drop 63 | } 64 | 65 | function Remove-GitChanges { 66 | param ( 67 | [ValidateNotNullorEmpty()] 68 | [ValidateScript({Test-Path $_})] 69 | [string] $File 70 | ) 71 | 72 | & "$(Find-Git)" checkout $File 73 | } 74 | 75 | function Remove-LastGitCommit { 76 | if ($(& "$(Find-Git)" diff --exit-code) -and $(& "$(Find-Git)" diff --cached --exit-code)) { 77 | & "$(Find-Git)" reset --soft HEAD~1 78 | } else { 79 | Write-Warning "Commit is already pushed... You will need to revert the changes instead." 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerContainerIPAddress.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerContainerIPAddress.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerContainerIPAddress 9 | 10 | ## SYNOPSIS 11 | 12 | Get the IP Address(es) of the container(s). 13 | 14 | ## SYNTAX 15 | 16 | ### All (Default) 17 | 18 | ```powershell 19 | Get-DockerContainerIPAddress [-Running] [] 20 | ``` 21 | 22 | ### Individual 23 | 24 | ```powershell 25 | Get-DockerContainerIPAddress [[-Id] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | The Get-DockerContainerIPAddress function retrieves the assigned IP address of Docker containers. 31 | 32 | ## EXAMPLES 33 | 34 | ### Example 1 35 | 36 | ```powershell 37 | PS C:\> Get-DockerContainerIPAddress 38 | 39 | Id IpAddress 40 | -- --------- 41 | d13a1b3408c9b399e20788ed211be9858597e86bed78ed81b3c898b217fa8cdc 172.17.0.3 42 | c3f015b67195997beaac3ea8f238d3b267ed0d97526614ddf47ffb793c011b6b 172.17.0.2 43 | ``` 44 | 45 | This example shows the IP address for the current containers. 46 | 47 | ### Example 2 48 | 49 | ```powershell 50 | PS C:\> Get-DockerContainerIPAddress -Id c3f015b67195997 51 | 172.17.0.2 52 | ``` 53 | 54 | This example shows the IP address for the specified container. 55 | 56 | ## PARAMETERS 57 | 58 | ### -Id 59 | 60 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 61 | 62 | ```yaml 63 | Type: String 64 | Parameter Sets: Individual 65 | Aliases: 66 | 67 | Required: False 68 | Position: 0 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -Running 75 | 76 | Limit to only running containers. 77 | 78 | ```yaml 79 | Type: SwitchParameter 80 | Parameter Sets: All 81 | Aliases: 82 | 83 | Required: False 84 | Position: Named 85 | Default value: None 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### CommonParameters 91 | 92 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 93 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-DockerContainerState.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-DockerContainerState.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-DockerContainerState 9 | 10 | ## SYNOPSIS 11 | 12 | Get the state of container(s). 13 | 14 | ## SYNTAX 15 | 16 | ### All (Default) 17 | 18 | ```powershell 19 | Get-DockerContainerState [-Running] [] 20 | ``` 21 | 22 | ### Individual 23 | 24 | ```powershell 25 | Get-DockerContainerState [[-Id] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | The Get-DockerContainerState function returns the state of containers. It can be filtered to return only running containers. 31 | 32 | ## EXAMPLES 33 | 34 | ### Example 1 35 | 36 | ```powershell 37 | PS C:\> Get-DockerContainerState 38 | 39 | Id State 40 | -- ----- 41 | 9a66ed0f53d2b71fb031f15c161f70b239ec96188f359ff68f9a24ae32cc0d95 exited 42 | d13a1b3408c9b399e20788ed211be9858597e86bed78ed81b3c898b217fa8cdc running 43 | c3f015b67195997beaac3ea8f238d3b267ed0d97526614ddf47ffb793c011b6b running 44 | ``` 45 | 46 | This example shows the state of each container. 47 | 48 | ### Example 2 49 | 50 | ```powershell 51 | PS C:\> Get-DockerContainerState d13a1b 52 | running 53 | ``` 54 | 55 | This example shows the state of a specific container. 56 | 57 | ## PARAMETERS 58 | 59 | ### -Id 60 | 61 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 62 | 63 | ```yaml 64 | Type: String 65 | Parameter Sets: Individual 66 | Aliases: 67 | 68 | Required: False 69 | Position: 0 70 | Default value: None 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### -Running 76 | 77 | Limit to only running containers. 78 | 79 | ```yaml 80 | Type: SwitchParameter 81 | Parameter Sets: All 82 | Aliases: 83 | 84 | Required: False 85 | Position: Named 86 | Default value: None 87 | Accept pipeline input: False 88 | Accept wildcard characters: False 89 | ``` 90 | 91 | ### CommonParameters 92 | 93 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 94 | -------------------------------------------------------------------------------- /Modules/DateTime/DateTime.psm1: -------------------------------------------------------------------------------- 1 | function Show-Calendar { 2 | [Alias("calendar")] 3 | param ( 4 | [DateTime] $Start = [DateTime]::Today, 5 | [DateTime] $End = $Start, 6 | $FirstDayOfWeek, 7 | [int[]] $HighlightDay, 8 | [string[]] $HighlightDate = [DateTime]::Today.ToString('yyyy-MM-dd') 9 | ) 10 | 11 | $Start = New-Object DateTime $Start.Year,$Start.Month,1 12 | $End = New-Object DateTime $End.Year ,$End.Month ,1 13 | [DateTime[]] $HighlightDate = [DateTime[]] $HighlightDate 14 | $dateTimeFormat = (Get-Culture).DateTimeFormat 15 | 16 | if ($FirstDayOfWeek) { 17 | $dateTimeFormat.FirstDayOfWeek = $FirstDayOfWeek 18 | } 19 | 20 | $currentDay = $Start 21 | 22 | while($Start -le $End) { 23 | while($currentDay.DayOfWeek -ne $dateTimeFormat.FirstDayOfWeek) { 24 | $currentDay = $currentDay.AddDays(-1) 25 | } 26 | 27 | $currentWeek = New-Object PsObject 28 | $dayNames = @() 29 | $weeks = @() 30 | 31 | while(($currentDay -lt $Start.AddMonths(1)) -or 32 | ($currentDay.DayOfWeek -ne $dateTimeFormat.FirstDayOfWeek)) { 33 | $dayName = "{0:ddd}" -f $currentDay 34 | if ($dayNames -notcontains $dayName) { 35 | $dayNames += $dayName 36 | } 37 | 38 | $displayDay = " {0,2} " -f $currentDay.Day 39 | 40 | if ($HighlightDate) { 41 | $compareDate = New-Object DateTime $currentDay.Year, $currentDay.Month, 42 | $currentDay.Day 43 | if ($HighlightDate -contains $compareDate) { 44 | $displayDay = "*" + ("{0,2}" -f $currentDay.Day) + "*" 45 | } 46 | } 47 | 48 | if ($HighlightDay -and ($HighlightDay[0] -eq $currentDay.Day)) { 49 | $displayDay = "[" + ("{0,2}" -f $currentDay.Day) + "]" 50 | $null,$HighlightDay = $HighlightDay 51 | } 52 | 53 | $currentWeek | Add-Member NoteProperty $dayName $displayDay 54 | 55 | $currentDay = $currentDay.AddDays(1) 56 | 57 | if ($currentDay.DayOfWeek -eq $dateTimeFormat.FirstDayOfWeek) { 58 | $weeks += $currentWeek 59 | $currentWeek = New-Object PsObject 60 | } 61 | } 62 | 63 | $calendar = $weeks | Format-Table $dayNames -AutoSize | Out-String 64 | $width = ($calendar.Split("`n") | Measure-Object -Maximum Length).Maximum 65 | $header = "{0:MMMM yyyy}" -f $Start 66 | $padding = " " * (($width - $header.Length) / 2) 67 | $displayCalendar = " `n" + $padding + $header + "`n " + $calendar 68 | $displayCalendar.TrimEnd() 69 | 70 | $Start = $Start.AddMonths(1) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Modules/MongoDB/MongoDB.psm1: -------------------------------------------------------------------------------- 1 | function Find-MongoDBPath { 2 | First-Path ` 3 | (Find-ProgramFiles 'MongoDB\Server\4.2\bin') ` 4 | (Find-ProgramFiles 'MongoDB\Server\4.0\bin') ` 5 | (Find-ProgramFiles 'MongoDB\Server\3.6\bin') ` 6 | (Find-ProgramFiles 'MongoDB\Server\3.4\bin') 7 | } 8 | 9 | function Export-MongoCollection { 10 | param( 11 | [Parameter(Mandatory = $true)] 12 | [ValidateNotNullOrEmpty()] 13 | [String]$JsonFile, 14 | [Parameter(Mandatory = $true)] 15 | [ValidateNotNullOrEmpty()] 16 | [String]$Database, 17 | [Parameter(Mandatory = $true)] 18 | [ValidateNotNullOrEmpty()] 19 | [String]$Collection 20 | ) 21 | 22 | $parameters = "--db $Database --collection $Collection --out $JsonFile" 23 | 24 | cmd / """$(Find-MongoDbPath)\mongoexport.exe"" $parameters" 25 | } 26 | 27 | function Import-MongoCollectionFromCsv { 28 | param( 29 | [Parameter(Mandatory = $true)] 30 | [ValidateScript({Test-Path -Path $_ })] 31 | [String]$CsvFile, 32 | [Parameter(Mandatory = $true)] 33 | [ValidateNotNullOrEmpty()] 34 | [String]$Database, 35 | [Parameter(Mandatory = $true)] 36 | [ValidateNotNullOrEmpty()] 37 | [String]$Collection 38 | 39 | ) 40 | 41 | $parameters = "--type csv --headerline $CsvFile -d $Database -c $Collection" 42 | 43 | cmd /c """$(Find-MongoDbPath)\mongoimport.exe"" $parameters" 44 | } 45 | 46 | function Import-MongoCollectionFromDump { 47 | param( 48 | [Parameter(Mandatory = $true)] 49 | [ValidateScript({Test-Path -Path $_ })] 50 | [String]$DumpFile, 51 | [Parameter(Mandatory = $true)] 52 | [ValidateNotNullOrEmpty()] 53 | [String]$Database, 54 | [Parameter(Mandatory = $true)] 55 | [ValidateNotNullOrEmpty()] 56 | [String]$Collection 57 | ) 58 | 59 | $parameters = "--headerline $CsvFile -d $Database -c $Collection" 60 | 61 | cmd /c """$(Find-MongoDbPath)\mongoimport.exe"" $parameters" 62 | } 63 | 64 | function Invoke-MongoDBClient { 65 | cmd /c """$(Find-MongoDbPath)\mongo.exe"" $args" 66 | } 67 | 68 | Set-Alias -Name mongodb-client -Value Invoke-MongoDBClient 69 | 70 | function Start-MongoDBServer { 71 | & sc.exe start MongoDB 72 | } 73 | 74 | Set-Alias -Name mongodb-start -Value Start-MongoDBServer 75 | 76 | function Stop-MongoDBServer { 77 | & sc.exe stop MongoDB 78 | } 79 | 80 | Set-Alias -Name mongodb-stop -Value Stop-MongoDBServer 81 | -------------------------------------------------------------------------------- /Modules/FileSystem/FileSystem.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'FileSystem.psm1' 3 | ModuleVersion = '2301.18.1' 4 | Description = "A collection of functions to deal with file systems including path operations." 5 | GUID = 'aaad40aa-30a0-495c-8377-53e89ea1ec11' 6 | Author = 'Julian Easterling' 7 | Copyright = '(c) Julian Easterling. Some rights reserved.' 8 | PowerShellVersion = '5.1' 9 | RequiredModules = @() 10 | RequiredAssemblies = @() 11 | ScriptsToProcess = @() 12 | TypesToProcess = @() 13 | FormatsToProcess = @() 14 | NestedModules = @( 15 | "FavoriteFolders.psm1" 16 | "Path.psm1" 17 | ) 18 | FunctionsToExport = @( 19 | "Add-FavoriteFolder" 20 | "Assert-FolderExists" 21 | "Clear-FavoriteFolder" 22 | "ConvertTo-UnixPath" 23 | "Copy-File" 24 | "Get-FavoriteFolder" 25 | "Get-FileEncoding" 26 | "Find-FirstPath" 27 | "Find-FolderSize" 28 | "Find-ProgramFiles" 29 | "Format-FileWithSpaceIndent" 30 | "Format-FileWithTabIndent" 31 | "Get-Path" 32 | "Get-Share" 33 | "Invoke-DownloadFile" 34 | "Invoke-PurgeFiles" 35 | "Invoke-TouchFile" 36 | "Invoke-UnzipFile" 37 | "New-FileLink" 38 | "New-Folder" 39 | "New-FolderLink" 40 | "New-Share" 41 | "Optimize-Path" 42 | "Push-FavoriteFolder" 43 | "Push-LastFavoriteFolder" 44 | "Remove-FavoriteFolder" 45 | "Remove-FilePermission" 46 | "Remove-Path" 47 | "Reset-Path" 48 | "Resolve-FullPath" 49 | "Set-FileInheritance" 50 | "Set-FilePermission" 51 | "Set-FileShortCut" 52 | "Set-Path" 53 | "Set-PathAtPosition" 54 | "Test-InPath" 55 | "Test-InPathAtPosition" 56 | ) 57 | CmdletsToExport = @() 58 | VariablesToExport = @() 59 | AliasesToExport = @( 60 | "Calculate-Folder-Size" 61 | "Calculate-FolderSize" 62 | "Clean-Path" 63 | "Download-File" 64 | "First-Path" 65 | "gd" 66 | "Get-FullFilePath" 67 | "Get-FullDirectoryPath" 68 | "New-FileShortCut" 69 | "Purge-Files" 70 | "touch" 71 | "Unzip-File" 72 | ) 73 | PrivateData = @{ 74 | PSData = @{ 75 | Tags = @( 76 | "dcjulian29" 77 | "filesystem" 78 | "file" 79 | "path" 80 | ) 81 | LicenseUri = 'https://github.com/dcjulian29/scripts-powershell/LICENSE.md' 82 | ProjectUri = 'https://github.com/dcjulian29/scripts-powershell' 83 | RequireLicenseAcceptance = $false 84 | ExternalModuleDependencies = @() 85 | } 86 | } 87 | HelpInfoURI = 'https://github.com/dcjulian29/scripts-powershell/tree/main/Modules/FileSystem' 88 | } 89 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Stop-DockerContainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Stop-DockerContainer.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Stop-DockerContainer 9 | 10 | ## SYNOPSIS 11 | 12 | Stop one or more running containers. 13 | 14 | ## SYNTAX 15 | 16 | ### ID (Default) 17 | 18 | ```powershell 19 | Stop-DockerContainer [-Id] [[-TimeOut] ] [] 20 | ``` 21 | 22 | ### All 23 | 24 | ```powershell 25 | Stop-DockerContainer [[-TimeOut] ] [-All] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | The Stop-DockerContainer functions stops one or more running containers. 31 | 32 | ## EXAMPLES 33 | 34 | ### Example 1 35 | 36 | ```powershell 37 | PS C:\> Stop-DockerContainer 20e11a17233e8 38 | 20e11a17233e8 39 | ``` 40 | 41 | This example stops the specified container. 42 | 43 | ### Example 2 44 | 45 | ```powershell 46 | PS C:\> Stop-DockerContainer -All 47 | 6abce5607388 48 | ca0405e0daf8 49 | 20e11a17233e 50 | 31bdb168cafd 51 | ``` 52 | 53 | This example stops all running containers. 54 | 55 | ## PARAMETERS 56 | 57 | ### -All 58 | 59 | Specify to stop all running containers. 60 | 61 | ```yaml 62 | Type: SwitchParameter 63 | Parameter Sets: All 64 | Aliases: 65 | 66 | Required: False 67 | Position: Named 68 | Default value: None 69 | Accept pipeline input: False 70 | Accept wildcard characters: False 71 | ``` 72 | 73 | ### -Id 74 | 75 | Specifies the UUID identifier that the Docker daemon uses to identify the container. 76 | 77 | ```yaml 78 | Type: String 79 | Parameter Sets: ID 80 | Aliases: Name 81 | 82 | Required: True 83 | Position: 0 84 | Default value: None 85 | Accept pipeline input: False 86 | Accept wildcard characters: False 87 | ``` 88 | 89 | ### -TimeOut 90 | 91 | Specifies the number of seconds to wait for container to exit before killing the container execution. 92 | 93 | ```yaml 94 | Type: Int32 95 | Parameter Sets: (All) 96 | Aliases: 97 | 98 | Required: False 99 | Position: 1 100 | Default value: None 101 | Accept pipeline input: False 102 | Accept wildcard characters: False 103 | ``` 104 | 105 | ### CommonParameters 106 | 107 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 108 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/New-DockerNfsVolume.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/New-DockerNfsVolume.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-DockerNfsVolume 9 | 10 | ## SYNOPSIS 11 | 12 | Create a Docker volume backed by an NFS share. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | New-DockerNfsVolume [-Name] [-Server] [-Path] [-ReadOnly] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The New-DockerNfsVolume function Create a Docker volume backed by an NFS share. It does no validation of the NFS share. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> New-DockerNfsVolume -Name "NfsTest1" -Server 10.10.10.10 -Path "/mnt/nfstest1" 30 | 31 | NfsTest1 32 | ``` 33 | 34 | This example creates a Docker volume that is backed by the specified NFS share. 35 | 36 | ## PARAMETERS 37 | 38 | ### -Name 39 | 40 | Specify volume name. 41 | 42 | ```yaml 43 | Type: String 44 | Parameter Sets: (All) 45 | Aliases: 46 | 47 | Required: True 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: False 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ### -Path 55 | 56 | Specify the path of the NFS share. 57 | 58 | ```yaml 59 | Type: String 60 | Parameter Sets: (All) 61 | Aliases: 62 | 63 | Required: True 64 | Position: 2 65 | Default value: None 66 | Accept pipeline input: False 67 | Accept wildcard characters: False 68 | ``` 69 | 70 | ### -ReadOnly 71 | 72 | Specify that the volume should only be mounted read only. 73 | 74 | ```yaml 75 | Type: SwitchParameter 76 | Parameter Sets: (All) 77 | Aliases: 78 | 79 | Required: False 80 | Position: Named 81 | Default value: None 82 | Accept pipeline input: False 83 | Accept wildcard characters: False 84 | ``` 85 | 86 | ### -Server 87 | 88 | Specify the name or IP Address of the host exporting the NFS share. 89 | 90 | ```yaml 91 | Type: String 92 | Parameter Sets: (All) 93 | Aliases: 94 | 95 | Required: True 96 | Position: 1 97 | Default value: None 98 | Accept pipeline input: False 99 | Accept wildcard characters: False 100 | ``` 101 | 102 | ### CommonParameters 103 | 104 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 105 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-FilePathForContainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-FilePathForContainer.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-FilePathForContainer 9 | 10 | ## SYNOPSIS 11 | 12 | Get a file path that Docker can use for mounting a volume. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-FilePathForContainer [-Path] [-MustBeChild] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-FilePathForContainer function gets a file path that Docker can use for mounting a volume. While similar to the Get-PathForContainer function, this function limits the operation to a file and will generate an error if the path doesn't point to a file. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-PathForContainer .\d8c927966343e5fd6d2627f7999b82c9 -MustBeChild 30 | 31 | ./d8c927966343e5fd6d2627f7999b82c9 32 | ``` 33 | 34 | This example returns the relative path to the specified child item. 35 | 36 | ### Example 2 37 | 38 | ```powershell 39 | PS C:\> Get-FilePathForContainer .\d8c927966343e5fd6d2627f7999b82c9\ 40 | 41 | Get-FilePathForContainer : File does not exists or object is not a file! 42 | At line:1 char:1 43 | + Get-FilePathForContainer .\d8c927966343e5fd6d2627f7999b82c9\ 44 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 45 | + CategoryInfo : ResourceUnavailable: (:) [Get-FilePathForContainer], ItemNotFoundException 46 | + FullyQualifiedErrorId : ResourceUnavailable,Get-FilePathForContainer 47 | ``` 48 | 49 | This example returns an error because the specified item was not a file. 50 | 51 | ## PARAMETERS 52 | 53 | ### -MustBeChild 54 | 55 | Specifies that the file must be in the current directory or a child directory and to return a relative path to it. 56 | 57 | ```yaml 58 | Type: SwitchParameter 59 | Parameter Sets: (All) 60 | Aliases: 61 | 62 | Required: False 63 | Position: Named 64 | Default value: None 65 | Accept pipeline input: False 66 | Accept wildcard characters: False 67 | ``` 68 | 69 | ### -Path 70 | 71 | Specify the path to a file. 72 | 73 | ```yaml 74 | Type: String 75 | Parameter Sets: (All) 76 | Aliases: 77 | 78 | Required: True 79 | Position: 0 80 | Default value: None 81 | Accept pipeline input: False 82 | Accept wildcard characters: False 83 | ``` 84 | 85 | ### CommonParameters 86 | 87 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 88 | -------------------------------------------------------------------------------- /Modules/OpenSSH/OpenSSHConfig.psm1: -------------------------------------------------------------------------------- 1 | function Get-OpenSSHConfig { 2 | begin { 3 | $hostTable = New-Object System.Data.DataTable("SshHosts") 4 | 5 | "Host", "HostName", "User", "Port", "IdentityFile" | ForEach-Object { 6 | $column = New-Object System.Data.DataColumn $_ 7 | $hostTable.Columns.Add($column) 8 | } 9 | 10 | $hostTable.Columns[3].DataType = [System.Type]::GetType("System.Int32") 11 | $content = Get-Content -Path $(Get-OpenSSHConfigFileName) 12 | } 13 | 14 | process { 15 | if ($content.Length -eq 0) { 16 | return $null 17 | } 18 | 19 | foreach ($line in $content) { 20 | if ($line -match '\s*#.*') { 21 | continue 22 | } 23 | 24 | if ($line -match '^[Hh]ost\s+([^\s]+)') { 25 | if ($row) { 26 | $hostTable.Rows.Add($row) 27 | } 28 | 29 | $row = $hostTable.NewRow(); 30 | $row["Host"] = $Matches[1] 31 | } 32 | 33 | if ($line -match '^\s*[^#]\s*[Hh]ost[Nn]ame\s+(\S+).*') { 34 | $row["HostName"] = $Matches[1] 35 | } 36 | 37 | 38 | if ($line -match '^\s*[^#]\s*[Us]ser\s+(\S+).*') { 39 | $row["User"] = $Matches[1] 40 | } 41 | 42 | if ($line -match '^\s*[^#]\s*[Pp]ort\s+(\S+).*') { 43 | $row["Port"] = $Matches[1] 44 | } 45 | 46 | if ($line -match '^\s*[^#]\s*[Ii]dentity[Ff]ile\s+(\S+).*') { 47 | $row["IdentityFile"] = $Matches[1] 48 | } 49 | } 50 | 51 | if ($row) { 52 | $hostTable.Rows.Add($row) 53 | } 54 | 55 | $default = $hostTable | Where-Object { $_.Host -eq "*" } 56 | 57 | foreach ($item in $hostTable) { 58 | if ($item.User.GetType().Name -eq "DBNull") { 59 | if ($default -and $default.User.GetType().Name -ne "DBNull") { 60 | $item.User = $default.User 61 | } else { 62 | $item.User = $env:USERNAME 63 | } 64 | } 65 | 66 | if ($item.Port.GetType().Name -eq "DBNull") { 67 | if ($default -and $default.Port.GetType().Name -ne "DBNull") { 68 | $item.Port = $default.Port 69 | } else { 70 | $item.Port = 22 71 | } 72 | } 73 | 74 | if ($item.IdentityFile.GetType().Name -eq "DBNull") { 75 | if ($default -and $default.IdentityFile.GetType().Name -ne "DBNull") { 76 | $item.IdentityFile = $default.IdentityFile 77 | } else { 78 | $item.IdentityFile = "" 79 | } 80 | } 81 | } 82 | } 83 | 84 | end { 85 | return $hostTable 86 | } 87 | } 88 | 89 | function Get-OpenSSHConfigFileName { 90 | if (Test-Path ${env:SystemDrive}\etc\ssh\config) { 91 | return "${env:SystemDrive}\etc\ssh\config" 92 | } 93 | 94 | return "${env:USERPROFILE}\.ssh\config" 95 | } 96 | -------------------------------------------------------------------------------- /Modules/Code/Code.psm1: -------------------------------------------------------------------------------- 1 | function Import-DevelopmentPowerShellModule { 2 | [CmdletBinding(DefaultParameterSetName="Module")] 3 | param ( 4 | [Parameter(Mandatory=$True, Position=0, ParameterSetName="Module")] 5 | [string[]]$Module, 6 | [Parameter(ParameterSetName="Module")] 7 | [Parameter(ParameterSetName="All")] 8 | [string]$Path = $(Get-DefaultCodeFolder), 9 | [Parameter(Mandatory=$True, ParameterSetName="All")] 10 | [switch]$All 11 | ) 12 | 13 | if (-not (Test-Path $Path)) { 14 | $PSCmdlet.ThrowTerminatingError((New-ErrorRecord ` 15 | -Message "'$Path' was not found or available!" ` 16 | -ExceptionType "System.IO.DirectoryNotFoundException" ` 17 | -ErrorId "ResourceUnavailable" ` 18 | -ErrorCategory "ResourceUnavailable" ` 19 | -TargetObject 'Import-DevelopmentPowerShellModule')) 20 | } 21 | 22 | $moduleFolder = (Get-ChildItem -Path $Path -Filter "Modules" ` 23 | -Recurse -ErrorAction SilentlyContinue).FullName 24 | 25 | if ($PSCmdlet.ParameterSetName -eq 'Module') { 26 | if (Test-Path "$moduleFolder\$Module\$Module.psd1") { 27 | $moduleFile = "$Module.psd1" 28 | } else { 29 | if (Test-Path "$moduleFolder\$Module\$Module.psm1") { 30 | $moduleFile = "$Module.psm1" 31 | } 32 | } 33 | 34 | $moduleFile = "$moduleFolder\$Module\$moduleFile" 35 | 36 | if (Test-Path $moduleFile) { 37 | $removal = Get-Module | Where-Object { $_.Name -eq $Module } 38 | 39 | do { 40 | if ($null -ne $removal) { 41 | Remove-Module -Name $removal -Force -Verbose:$false #$Verbose.IsPresent 42 | } 43 | 44 | $removal = Get-Module | Where-Object { $_.Name -eq $Module } 45 | } until ($null -eq $removal) 46 | 47 | Import-Module -Global $moduleFile -Verbose:($PSBoundParameters.ContainsKey('Verbose')) 48 | } else { 49 | $PSCmdlet.ThrowTerminatingError((New-ErrorRecord ` 50 | -Message "'$Module' was not found or available!" ` 51 | -ExceptionType "System.IO.DirectoryNotFoundException" ` 52 | -ErrorId "ResourceUnavailable" ` 53 | -ErrorCategory "ResourceUnavailable" ` 54 | -TargetObject $Module)) 55 | } 56 | } else { 57 | $modules = (Get-ChildItem -Path $moduleFolder).Name 58 | 59 | foreach ($module in $modules) { 60 | if ($module -eq "GlobalScripts") { 61 | continue 62 | } 63 | 64 | Import-DevelopmentPowerShellModule -Module $module -Path $Path ` 65 | -Verbose:($PSBoundParameters.ContainsKey('Verbose')) 66 | } 67 | } 68 | 69 | Get-Module -All | Select-Object Name, Version, Path | ` 70 | Where-Object { $_.Path -like "$moduleFolder*"} | Format-Table 71 | } 72 | 73 | Set-Alias -Name idpsm -Value Import-DevelopmentPowerShellModule 74 | -------------------------------------------------------------------------------- /Modules/PSExtensions/docs/Get-PowerShellVerbs.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSExtensions-help.xml 3 | Module Name: PSExtensions 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PSExtensions/docs/Get-PowershellVerbs.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PowershellVerbs 9 | 10 | ## SYNOPSIS 11 | 12 | Return a list of Approved Powershell Verbs. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-PowershellVerbs [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-PowershellVerbs returns the list of approved verbs in the current Powershell session. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-PowershellVerbs 30 | 31 | Verb AliasPrefix Group Description 32 | ---- ----------- ----- ----------- 33 | Add a Common Adds a resource to a container, or attaches an item to another item 34 | Approve ap Lifecycle Confirms or agrees to the status of a resource or process 35 | Assert as Lifecycle Affirms the state of a resource 36 | Backup ba Data Stores data by replicating it 37 | Block bl Security Restricts access to a resource 38 | Build bd Lifecycle Creates an artifact (usually a binary or document) out of some set of input files (usually s… 39 | Checkpoint ch Data Creates a snapshot of the current state of the data or of its configuration 40 | Clear cl Common Removes all the resources from a container but does not delete the container 41 | Close cs Common Changes the state of a resource to make it inaccessible, unavailable, or unusable 42 | Compare cr Data Evaluates the data from one resource against the data from another resource 43 | Complete cmp Lifecycle Concludes an operation 44 | 45 | ... 46 | 47 | Use u Other Uses or includes a resource to do something 48 | Wait w Lifecycle Pauses an operation until a specified event occurs 49 | Watch wc Common Continually inspects or monitors a resource for changes 50 | Write wr Communications Adds information to a target 51 | ``` 52 | 53 | This example shows the current approved verbs that can be used for Powershell cmdlets. 54 | 55 | ## PARAMETERS 56 | 57 | ### CommonParameters 58 | 59 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 60 | 61 | ## INPUTS 62 | 63 | ## OUTPUTS 64 | 65 | ## NOTES 66 | 67 | ## RELATED LINKS 68 | -------------------------------------------------------------------------------- /Modules/PowershellForDocker/docs/Get-PathForContainer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PowershellForDocker-help.xml 3 | Module Name: PowershellForDocker 4 | online version: https://github.com/dcjulian29/scripts-powershell/blob/main/Modules/PowershellForDocker/docs/Get-PathForContainer.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PathForContainer 9 | 10 | ## SYNOPSIS 11 | 12 | Get a path that Docker can use for mounting a volume. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-PathForContainer [-Path] [-MustBeChild] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The Get-PathForContainer function gets a path that Docker can use for mounting a volume. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-FilePathForContainer .\d8f9687d-ca2d-4e84-bbf2-079cfbe5dad5.tmp.ico 30 | 31 | /mnt/c/Users/user/AppData/Local/Temp/d8f9687d-ca2d-4e84-bbf2-079cfbe5dad5.tmp.ico 32 | ``` 33 | 34 | This example returns an absolute path to the specified directory. 35 | 36 | ### Example 2 37 | 38 | ```powershell 39 | PS C:\> Get-PathForContainer .\d8c927966343e5fd6d2627f7999b82c9 -MustBeChild 40 | 41 | ./d8c927966343e5fd6d2627f7999b82c9 42 | ``` 43 | 44 | This example returns a relative path to the specified child directory. 45 | 46 | ### Example 3 47 | 48 | ```powershell 49 | PS C:\> Get-PathForContainer $env:WINDIR -MustBeChild 50 | 51 | Get-PathForContainer : Path 'C:\WINDOWS' is not a child of the current directory! 52 | + Get-PathForContainer $env:WINDIR -MustBeChild 53 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 | + CategoryInfo : ResourceUnavailable: (:) [Get-PathForContainer], ItemNotFoundException 55 | + FullyQualifiedErrorId : ResourceUnavailable,Get-PathForContainer 56 | ``` 57 | 58 | This example shows an error because the Windows directory is not a child directory of the current directory. 59 | 60 | ## PARAMETERS 61 | 62 | ### -MustBeChild 63 | 64 | Specifies that the directory must be a child item and to return a relative path to it. 65 | 66 | ```yaml 67 | Type: SwitchParameter 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: False 72 | Position: Named 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### -Path 79 | 80 | Specify the path to a file or folder. 81 | 82 | ```yaml 83 | Type: String 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: True 88 | Position: 0 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### CommonParameters 95 | 96 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 97 | -------------------------------------------------------------------------------- /Modules/Logging/Logging.psm1: -------------------------------------------------------------------------------- 1 | function Get-LogFolder { 2 | if (Test-Path "$env:SystemDrive\etc") { 3 | if (-not (Test-Path "$env:SystemDrive\etc\log")) { 4 | New-Item -Path "$env:SystemDrive\etc\log" -ItemType Directory | Out-Null 5 | } 6 | 7 | "$env:SystemDrive\etc\log" 8 | } else { 9 | "$env:TEMP" 10 | } 11 | } 12 | 13 | function Get-LogFileName { 14 | param ( 15 | [Parameter(Mandatory=$true)] 16 | [string]$Suffix, 17 | [psobject]$Date = $(Get-Date) 18 | ) 19 | 20 | $(Get-LogFolder) + "\" ` 21 | + $Date.ToString("yyyMMdd_HHmmss") + "-$Suffix.log" 22 | } 23 | 24 | function Optimize-LogFolder { 25 | param ( 26 | [Parameter(Mandatory=$true)] 27 | [string]$Filter, 28 | [string]$Path = $(Get-LogFolder), 29 | [Int32]$NumberToKeep = 5, 30 | [switch]$Compress 31 | ) 32 | 33 | $files = Get-ChildItem -Path $Path -Filter "*$Filter*.log" | ` 34 | Sort-Object -Property LastWriteTime -Descending | ` 35 | Select-Object -Skip $NumberToKeep 36 | 37 | if ($Compress) { 38 | $files | ForEach-Object { 39 | Compress-Archive -Path $_.FullName ` 40 | -DestinationPath "$($_.DirectoryName)\$($_.BaseName).zip" ` 41 | -Force 42 | } 43 | } 44 | 45 | $files | ForEach-Object { Remove-Item -Path $_.FullName -Force } 46 | } 47 | 48 | function Start-ApplicationTranscript { 49 | [CmdletBinding()] 50 | param ( 51 | [string] $LogFile = $(Get-LogFileName -Suffix $PID) 52 | ) 53 | 54 | Start-Transcript -Path $LogFile -Append 55 | } 56 | 57 | Set-Alias -Name Stop-ApplicationTranscript -Value Stop-Transcript 58 | 59 | function Write-Log { 60 | param ( 61 | [Parameter(Mandatory=$true)] 62 | [string] $Message, 63 | [string] $LogFile = "$(Get-LogFolder)\_default.log", 64 | [switch] $NoOutput, 65 | [switch] $Warning, 66 | [switch] $NoTimestamp, 67 | [switch] $NoFileOutput 68 | ) 69 | 70 | if ($NoTimestamp) { 71 | $text = "$Message" 72 | } else { 73 | $text = "$(Get-Date -Format "MM/dd/yyyy HH:mm:ss") : $Message" 74 | } 75 | 76 | if (-not ($NoFileOutput)) { 77 | if (-not (Test-Path $(Split-Path $LogFile))) { 78 | New-Item -Path $(Split-Path $LogFile) -ItemType Directory | Out-Null 79 | } 80 | 81 | if (Test-Path $LogFile) { 82 | Add-Content -Path $LogFile -Value $text 83 | } else { 84 | Set-Content -Path $LogFile -Value $text 85 | } 86 | } 87 | 88 | if (-not $NoOutput) { 89 | if ($Warning) { 90 | Write-Warning $text 91 | } else { 92 | Write-Output $text 93 | } 94 | } 95 | } 96 | --------------------------------------------------------------------------------