This commit is contained in:
Zack Meier
2026-04-15 15:45:50 -05:00
commit 1d304511b8
613 changed files with 140998 additions and 0 deletions
@@ -0,0 +1,49 @@
trigger:
- main
name: 'ITD.All-General'
variables:
major: 1
minor: 0
patch: $(Build.BuildID)
buildVer: $(major).$(minor).$(Build.BuildID)
pool: itdwinautop1
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: PowerShell@2
inputs:
filePath: '$(System.DefaultWorkingDirectory)/Build/build.ps1'
- task: NuGetCommand@2
inputs:
command: 'pack'
packagesToPack: '$(System.DefaultWorkingDirectory)/ITD.All-General.nuspec'
versioningScheme: byEnvVar
versionEnvVar: buildVer
buildProperties: 'VERSIONHERE=$(buildVer)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'NuGetPackage'
publishLocation: 'Container'
- stage: Deploy
jobs:
- job: Deploy
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'NuGetPackage'
itemPattern: '**'
targetPath: '$(Pipeline.Workspace)'
- task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/ITD.All-General.$(major).$(minor).$(Build.BuildID).nupkg'
nuGetFeedType: external
publishFeedCredentials: 'ITD_PwshGallery'
@@ -0,0 +1,17 @@
$buildVersion = $env:BUILDVER
$moduleName = 'ITD.All-General'
$manifestPath = Join-Path -Path $env:SYSTEM_DEFAULTWORKINGDIRECTORY -ChildPath "$moduleName.psd1"
$modulePath = Join-Path -Path $env:SYSTEM_DEFAULTWORKINGDIRECTORY -ChildPath "$moduleName.psm1"
## Update build version in manifest
$manifestContent = Get-Content -Path $manifestPath -Raw
$manifestContent = $manifestContent -replace '<ModuleVersion>', $buildVersion
## Update functions to export in manifest
Import-Module $modulePath
$funcStrings = (Get-Module ITD.All-General).ExportedCommands.Values.Name
$funcStrings = "'$($funcStrings -join "','")'"
$manifestContent = $manifestContent -replace "<FunctionsToExport>", $funcStrings
$manifestContent | Set-Content -Path $manifestPath
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<package>
<metadata>
<id>ITD.All-General</id>
<version>$VERSIONHERE$</version>
<authors>Zack Meier</authors>
<description>QoL functions that don't fit into another module</description>
</metadata>
<files>
<file src="**" exclude="**\.git\**;**\Build\**" />
</files>
</package>
@@ -0,0 +1,11 @@
@{
RootModule = 'ITD.All-General.psm1'
ModuleVersion = '<ModuleVersion>'
GUID = '9c9219d5-d7be-49e5-8448-49c50df94eda'
Author = 'Zack Meier'
CompanyName = 'State of North Dakota'
Description = "QoL functions that don't fit into another module"
PowerShellVersion = '5.1'
CompatiblePSEditions = 'Desktop', 'Core'
FunctionsToExport = @(<FunctionsToExport>)
}
@@ -0,0 +1,23 @@
#Get public and private function definition files.
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue )
#Dot source the files
Foreach($import in @($Public + $Private))
{
Try
{
. $import.fullname
}
Catch
{
Write-Error -Message "Failed to import function $($import.fullname): $_"
}
}
# Here I might...
# Read in or create an initial config file and variable
# Export Public functions ($Public.BaseName) for WIP modules
# Set variables visible to the module and its functions only
Export-ModuleMember -Function $Public.Basename
@@ -0,0 +1,32 @@
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
$servers=@"
server1.xyz.com
servers2.xyz.com
@"
$servers = ConvertTo-Array -MultiLineString $servers
.EXAMPLE
Another example of how to use this cmdlet
#>
function ConvertTo-Array {
[CmdletBinding()]
Param
(
[string]
$MultiLineString
)
Begin {
}
Process {
$result = @($MultiLineString -split '[\r\n]+')
}
End {
return $result
}
}
@@ -0,0 +1,43 @@
<#
.SYNOPSIS
A short one-line action-based description, e.g. 'Tests if a function is valid'
.DESCRIPTION
A longer description of the function, its purpose, common use cases, etc.
.NOTES
Information or caveats about the function e.g. 'This function is not supported in Linux'
.LINK
Specify a URI to a help page, this will show when Get-Help -Online is used.
.EXAMPLE
Test-MyTestFunction -Verbose
Explanation of the function or its result. You can include multiple examples with additional .EXAMPLE lines
#>
function Get-SslCertificate {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$DNSName
)
process {
Write-Verbose "Checking certificate for $DNSName"
$tcp = [Net.Sockets.TcpClient]::new($DNSName, 443)
$ssl = [Net.Security.SslStream]::new(
$tcp.GetStream(),
$false,
{ $true }
)
$ssl.AuthenticateAsClient($DNSName)
$cert = [Security.Cryptography.X509Certificates.X509Certificate2]::new(
$ssl.RemoteCertificate
)
$ssl.Dispose()
$tcp.Dispose()
$cert
}
}
@@ -0,0 +1,49 @@
<#
.Synopsis
Verify AD credentials are valid
.DESCRIPTION
Verify AD credentials are valid ##
.EXAMPLE
Test-ADCredential -Credential <PSCredential>
#>
function Test-ADCredential {
[CmdletBinding()]#
Param
(
[Parameter(Mandatory = $true)]
[PSCredential]
$Credential
)
Begin {
}
Process {
If ($Credential -eq $null) {
Write-Warning "Credentials empty"
$status = $true
}
Else {
$username = $Credential.username
$password = $Credential.GetNetworkCredential().password
$CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
#($ValidateCredential = ) | Out-Null
If ($DS.ValidateCredentials($UserName, $Password) -eq $false) {
$password = $null
Write-Error "Invalid credentials or locked account."
$status = $false
}
Else {
$status = $true
}
$password = $null
}
}
End {
}
}
@@ -0,0 +1,50 @@
<#
.SYNOPSIS
Removes old versions of ITD modules
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
.INPUTS
Inputs to this cmdlet (if any)
.OUTPUTS
Output from this cmdlet (if any)
.NOTES
General notes
.COMPONENT
The component this cmdlet belongs to
.ROLE
The role this cmdlet belongs to
.FUNCTIONALITY
The functionality that best describes this cmdlet
#>
function Uninstall-ITDModuleOldVersion {
[CmdletBinding()]
Param
(
)
begin {
}
process {
$InstalledModules = Get-InstalledModule -Name ITD.*
try {
$InstalledModules | ForEach-Object {
$CurrentVersion = $_.Version
Get-InstalledModule -Name $_.Name -AllVersions | Where-Object -Property Version -LT -Value $CurrentVersion
} | Uninstall-Module -Verbose
}
catch {
}
}
end {
}
}
@@ -0,0 +1,33 @@
<#
.SYNOPSIS
A short one-line action-based description, e.g. 'Tests if a function is valid'
.DESCRIPTION
A longer description of the function, its purpose, common use cases, etc.
.NOTES
Information or caveats about the function e.g. 'This function is not supported in Linux'
.LINK
Specify a URI to a help page, this will show when Get-Help -Online is used.
.EXAMPLE
Test-MyTestFunction -Verbose
Explanation of the function or its result. You can include multiple examples with additional .EXAMPLE lines
#>
function Update-ITDModule {
[CmdletBinding()]
param (
)
begin {
}
process {
$InstalledModules = Get-InstalledModule -Name ITD.*
Update-Module -Name $InstalledModules.Name
}
end {
}
}
@@ -0,0 +1,20 @@
# Introduction
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
# Getting Started
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
1. Installation process
2. Software dependencies
3. Latest releases
4. API references
# Build and Test
TODO: Describe and show how to build your code and run the tests.
# Contribute
TODO: Explain how other users and developers can contribute to make your code better.
If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
- [ASP.NET Core](https://github.com/aspnet/Home)
- [Visual Studio Code](https://github.com/Microsoft/vscode)
- [Chakra Core](https://github.com/Microsoft/ChakraCore)