update
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
||||
# It all starts with a single line of powershell code.
|
||||
$ITDModules = Get-Module -Name ITD* -ListAvailable
|
||||
|
||||
Write-Output $ITDModules
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
# It all starts with a single line of powershell code.
|
||||
Get-Service -ErrorAction SilentlyContinue
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
Write-Verbose "UAJob" -Verbose
|
||||
$UAJob
|
||||
|
||||
Write-Verbose "UAJobId" -Verbose
|
||||
$UAJobId
|
||||
|
||||
Write-Verbose "UAScript" -Verbose
|
||||
$UAScript
|
||||
|
||||
Write-Verbose "UAScriptId" -Verbose
|
||||
$UAScriptId
|
||||
|
||||
Write-Verbose "UASchedule" -Verbose
|
||||
$UASchedule
|
||||
|
||||
Write-Verbose "UAScheduleId" -Verbose
|
||||
$UAScheduleId
|
||||
|
||||
Write-Verbose "AccessToken" -Verbose
|
||||
$AccessToken
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
# It all starts with a single line of powershell code.
|
||||
$Secret:svcitdiaasauto
|
||||
$Secret:testuser01
|
||||
$Secret:SNowVMCred
|
||||
$Secret:AzureVMServicePrincipal
|
||||
$Secret:svcitdvmvcauto
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
# It all starts with a single line of powershell code.
|
||||
$Secret:itdpsu1
|
||||
$Secret:norolecred
|
||||
$Secret:vmcred
|
||||
$Secret:wincred
|
||||
$Secret:svcitdvmsnapmgr
|
||||
$Sercet:svcitdiaasauto_test
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
# It all starts with a single line of powershell code.
|
||||
$ServerInstance = "itdintsql22p1.nd.gov\INTSQL22P1"
|
||||
$Database = "ITD-Systems-Automation"
|
||||
$SnapshotTable = "Infra_VMware_VirtualMachine_VMSnapshots_NPD"
|
||||
|
||||
$SqlQuery = "INSERT INTO [Infra_VMware_VirtualMachine_VMSnapshots_NPD] (VMName, DateTime, RequestedBy, DurationHours,Status,ExpireDateTime,NotifyEmail,PSUJobIdRequest) Values ('itdscmt1.nd.gov', '2024/07/30 09:24:08', 'prvzmeier@nd.gov', 2, 'Requested', '2024/07/30 11:23:51','zmeier@nd.gov','');SELECT SCOPE_IDENTITY();"
|
||||
(Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $SqlQuery -Credential $Secret:itdpsu1 -Verbose)
|
||||
|
||||
+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
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
# It all starts with a single line of powershell code. # TEST
|
||||
Get-PSUIdentity
|
||||
Reference in New Issue
Block a user