update
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
Param(
|
||||
[string]
|
||||
$Name,
|
||||
|
||||
[ValidateSet(
|
||||
'Infra-ActiveDirectory.Object',
|
||||
'Infra-Azure.VirtualMachine',
|
||||
'Infra-Monitoring-Solarwinds',
|
||||
'Infra-VMware.Administration',
|
||||
'Infra-VMware.VirtualMachine',
|
||||
'Infra-VMware.Snapshot',
|
||||
'ITD-WindowsServer.FileManagement',
|
||||
'ITD-WindowsServer.General',
|
||||
'ITD-WindowsServer.Lifecycle',
|
||||
'Shared-Powerschool'
|
||||
)]
|
||||
[string]
|
||||
$Path
|
||||
)
|
||||
|
||||
switch ($Path){
|
||||
<# example switch condition and actions
|
||||
{ $_ -like "App-XXXXX"} {$TagNamesEnforced = @('Shared-XXXXX_Modify)}
|
||||
#>
|
||||
{ $_ -eq "Infra-ActiveDirectory.Object" } { $TagNamesEnforced = @('ITD-WindowsServer_Modify') }
|
||||
{ $_ -like "Infra-Azure.*"} {$TagNamesEnforced = @('Infra-VMware_Modify')}
|
||||
{ $_ -like "Infra-Monitoring-Solarwinds*" } { $TagNamesEnforced = @('ITD-WindowsServer_Modify') }
|
||||
{ $_ -like "Infra-VMware*" } { $TagNamesEnforced = @('Infra-VMware_Modify') }
|
||||
{ $_ -like "ITD-WindowsServer*" } { $TagNamesEnforced = @('ITD-WindowsServer_Modify') }
|
||||
{ $_ -like "Shared-PowerSchool*" } { $TagNamesEnforced = @('Shared-PowerSchool_Modify') }
|
||||
|
||||
}
|
||||
New-PSUScript -Name $Name -Path "$Path\$Name" -Tag @($TagNamesEnforced) -ScriptBlock {# It all starts with a single line of powershell code.
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#######
|
||||
Write-Verbose -Message "Determine if ITD_PwshGallery is registered" -Verbose
|
||||
If(Get-PSRepository -Name ITD_PwshGallery -ErrorAction SilentlyContinue){
|
||||
Write-Verbose -Message "ITD_PwshGallery found." -Verbose
|
||||
} Else {
|
||||
$RegisterPSRepositoryParams = @{
|
||||
Name = 'ITD_PwshGallery';
|
||||
InstallationPolicy = 'Trusted';
|
||||
SourceLocation = 'https://powershell.nd.gov/ITD_PwshGallery/nuget/';
|
||||
PublishLocation = 'https://powershell.nd.gov/ITD_PwshGallery/nuget/';
|
||||
ScriptSourceLocation = 'https://powershell.nd.gov/ITD_PwshGallery/nuget/';
|
||||
ScriptPublishLocation = 'https://powershell.nd.gov/ITD_PwshGallery/nuget/';
|
||||
}
|
||||
Register-PSRepository @RegisterPSRepositoryParams
|
||||
}
|
||||
|
||||
Write-Verbose -Message "Retrieve list of all available modules and versions"
|
||||
$ITDModules = Find-Module -Name "ITD.*" -Repository ITD_PwshGallery
|
||||
|
||||
|
||||
Write-Verbose -Message "Compare local module versions to repository versions, and update if needed"
|
||||
ForEach($ITDModule in $ITDModules){
|
||||
$VersionsAvailable = $null
|
||||
$MostRecentVersion = $null
|
||||
$RepoVersion = $null
|
||||
|
||||
$VersionsAvailable = Get-Module -Name $ITDModule.name -ListAvailable
|
||||
$MostRecentVersion = $VersionsAvailable | Sort-Object Version -Descending | Select -First 1
|
||||
$RepoVersion = $ITDModule.Version
|
||||
|
||||
If($null -eq $MostRecentVersion) {
|
||||
Write-Verbose -Message ($ITDModule.Name + " was not found locally, installing module now.") -Verbose
|
||||
Install-Module -Name $ITDModule.Name -Scope AllUsers -Repository ITD_PwshGallery
|
||||
} Else {
|
||||
Write-Verbose -Message ($ITDModule.Name + " was found locally, comparing versions and updating if needed..") -Verbose
|
||||
Write-Host -Message ($ITDModule.Name)
|
||||
Write-Host -Message ("Local version is " + $MostRecentVersion.Version)
|
||||
Write-Host -Message ("The Repo version is " + $RepoVersion)
|
||||
Write-Host -Message ("")
|
||||
Update-Module -Name $ITDModule.Name -Scope AllUsers -Verbose
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user