Fix image-builder scripts
* Fix encoding issues * Convert all files to UTF-8 * Fix indendation and hanging whitespaces * Add new vairable LIBVIRT_IMAGES_DIR to be able to use faster drive for KVM images * Fix unattended template for sysrep on Windows Server 2008 R2 Change-Id: Ifb4df8c0eeddf1698a6e4c691f48e92406bac770
This commit is contained in:
parent
486ba98ba5
commit
aac6c62d60
|
@ -1,4 +1,4 @@
|
|||
<#
|
||||
<#
|
||||
Naming convention:
|
||||
|
||||
== Normal variables
|
||||
|
|
Binary file not shown.
|
@ -6,10 +6,10 @@ Function ConvertTo-Base64String {
|
|||
param (
|
||||
[Parameter(Position=1,ParameterSetName="FromString")]
|
||||
[String] $String,
|
||||
|
||||
|
||||
[Parameter(ParameterSetName="FromFile")]
|
||||
[String] $Path,
|
||||
|
||||
|
||||
[Parameter(ParameterSetName="FromFile")]
|
||||
[Int] $ChunkSize = 5KB,
|
||||
|
||||
|
@ -24,11 +24,11 @@ Function ConvertTo-Base64String {
|
|||
"FromFile" {
|
||||
$FileStream = [IO.File]::Open($Path, [System.IO.FileMode]::Open)
|
||||
$BytesToRead = $FileStream.Length
|
||||
|
||||
|
||||
if ($OneChunk) {
|
||||
$ChunkSize = $BytesToRead
|
||||
}
|
||||
|
||||
|
||||
$Bytes = New-Object Byte[] $ChunkSize
|
||||
while ($BytesToRead -gt 0) {
|
||||
if ($BytesToRead -lt $ChunkSize) {
|
||||
|
@ -38,7 +38,7 @@ Function ConvertTo-Base64String {
|
|||
#Write-Host ("BytesToRead: {0}, ChunkSize: {1}" -f $BytesToRead, $ChunkSize )
|
||||
$BytesRead = $FileStream.Read($Bytes, 0, $ChunkSize)
|
||||
$BytesToRead -= $BytesRead
|
||||
|
||||
|
||||
[System.Convert]::ToBase64String($Bytes)
|
||||
}
|
||||
$FileStream.Close()
|
||||
|
@ -55,10 +55,10 @@ Function ConvertFrom-Base64String {
|
|||
param (
|
||||
[Parameter(Position=1,ValueFromPipeline=$true)]
|
||||
[String] $Base64String,
|
||||
|
||||
|
||||
[Parameter(ParameterSetName="ToFile")]
|
||||
[String] $Path,
|
||||
|
||||
|
||||
[Parameter(ParameterSetName="ToString")]
|
||||
[Switch] $ToString
|
||||
)
|
||||
|
|
|
@ -3,13 +3,13 @@ function New-ExecutionResult {
|
|||
[Object] $Result = $null,
|
||||
[Switch] $IsException
|
||||
)
|
||||
|
||||
|
||||
$obj = New-Object -TypeName PSObject |
|
||||
Add-Member -Type NoteProperty -Name IsException -Value ([Bool] $IsException) -PassThru |
|
||||
Add-Member -Type NoteProperty -Name Result -Value $Result -PassThru
|
||||
|
||||
|
||||
$obj.PSTypeNames.Insert(0, 'Custom.MuranoAgentExecutionsResult')
|
||||
|
||||
|
||||
return $obj
|
||||
}
|
||||
|
||||
|
@ -21,18 +21,18 @@ function Add-ExecutionResult {
|
|||
[Object] $Result,
|
||||
[Switch] $IsException
|
||||
)
|
||||
|
||||
|
||||
if (@($InputObject.Result)[0].PSTypeNames -contains 'Custom.MuranoAgentExecutionsResult') {
|
||||
$InputObject.Result = @($InputObject.Result) + @(New-ExecutionResult $Result -IsException:$IsException)
|
||||
}
|
||||
else {
|
||||
$InputObject.Result = New-ExecutionResult $Result -IsException:$IsException
|
||||
}
|
||||
|
||||
|
||||
if (-not $InputObject.IsException) {
|
||||
$InputObject.IsException = ([Bool] $IsException)
|
||||
}
|
||||
|
||||
|
||||
$InputObject
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ function Load-FromJsonFile {
|
|||
[String] $Path = ''
|
||||
)
|
||||
Write-LogDebug "Loading JSON from file '$Path'"
|
||||
|
||||
|
||||
if ([IO.File]::Exists($Path)) {
|
||||
Get-Content $Path | ConvertFrom-Json
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ function Invoke-ExecutionPlan {
|
|||
catch {
|
||||
$ExecutionResult = New-ExecutionResult
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if ($ExecutionPlan -eq '') {
|
||||
|
@ -99,7 +99,7 @@ function Invoke-ExecutionPlan {
|
|||
$ExecutionResult | ConvertTo-Json -Depth 10
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
foreach ($Base64Script in $ExecutionPlanObject.Scripts) {
|
||||
$ExecutionPlanScript = ConvertFrom-Base64String -Base64String $Base64Script -ToString
|
||||
|
@ -124,11 +124,11 @@ $ExecutionPlanScript
|
|||
Write-LogDebug "Invoking command '$command'"
|
||||
$ExecutionResult = Add-ExecutionResult $ExecutionResult $(Invoke-Expression $Command)
|
||||
}
|
||||
|
||||
|
||||
$CommandIndex++
|
||||
$ExecutionPlanObject.NextCommandIndex = $CommandIndex
|
||||
Save-ToJsonFile $ExecutionPlanCache_plan $ExecutionPlanObject
|
||||
|
||||
|
||||
Save-ToJsonFile $ExecutionPlanCache_result $ExecutionResult
|
||||
}
|
||||
}
|
||||
|
@ -137,11 +137,11 @@ $ExecutionPlanScript
|
|||
$ExecutionResult | ConvertTo-Json -Depth 10
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if ($CommandIndex -ge $ExecutionPlanObject.Commands.Count) {
|
||||
Write-LogDebug "All commands were executed successfully!"
|
||||
}
|
||||
|
||||
|
||||
$ExecutionResult | ConvertTo-Json -Depth 10
|
||||
}
|
||||
|
||||
|
@ -151,17 +151,15 @@ function ConvertTo-PowerShellCommand {
|
|||
param (
|
||||
[Object] $InputObject
|
||||
)
|
||||
|
||||
|
||||
$Command = $InputObject.Name
|
||||
|
||||
$InputObject.Arguments |
|
||||
$InputObject.Arguments |
|
||||
Get-Member -MemberType NoteProperty |
|
||||
ForEach-Object {
|
||||
$ArgName = $_.Name
|
||||
$Command += " -$ArgName `"" + $InputObject.Arguments.$ArgName + "`""
|
||||
}
|
||||
|
||||
|
||||
$Command
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Function Stop-Execution {
|
||||
Function Stop-Execution {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Breaks execution with specified error code.
|
||||
|
@ -9,21 +9,21 @@ Function break script execution with error code provided. Error code may be 0 in
|
|||
It also tries to parse ErrorRecord or Exception object (if provided) and logs this information.
|
||||
#>
|
||||
[CmdletBinding(DefaultParameterSetName="Exception")]
|
||||
|
||||
param (
|
||||
|
||||
param (
|
||||
[Parameter(Position=1,ParameterSetName="Exception")]
|
||||
$InputObject = $null,
|
||||
|
||||
$InputObject = $null,
|
||||
|
||||
[Parameter(ParameterSetName="ErrorString")]
|
||||
[String] $ExitString = "",
|
||||
|
||||
[String] $ExitString = "",
|
||||
|
||||
[Parameter(ParameterSetName="ErrorString")]
|
||||
[Int] $ExitCode = 0,
|
||||
|
||||
[Int] $ExitCode = 0,
|
||||
|
||||
[Parameter(ParameterSetName="ErrorString")]
|
||||
[Switch] $Success
|
||||
)
|
||||
|
||||
[Switch] $Success
|
||||
)
|
||||
|
||||
Function Exit-Function {
|
||||
if ($ExitCode -eq 0) {
|
||||
Write-LogInfo ( "STOP ({0}):`n{1}" -f $ExitCode, $ExitString )
|
||||
|
@ -31,7 +31,7 @@ It also tries to parse ErrorRecord or Exception object (if provided) and logs th
|
|||
else {
|
||||
Write-LogFatal ( "STOP ({0}):`n{1}" -f $ExitCode, $ExitString )
|
||||
}
|
||||
|
||||
|
||||
Write-Log "__StopExecutionPreference__ = '$__StopExecutionPreference__'"
|
||||
switch ("$__StopExecutionPreference__") {
|
||||
"Exit" {
|
||||
|
@ -55,19 +55,19 @@ It also tries to parse ErrorRecord or Exception object (if provided) and logs th
|
|||
}
|
||||
|
||||
switch($PSCmdlet.ParameterSetName) {
|
||||
"Exception" {
|
||||
"Exception" {
|
||||
#----------
|
||||
if ($InputObject -eq $null) {
|
||||
$ExitString = "***** SCRIPT INTERRUPTED *****"
|
||||
$ExitString = "***** SCRIPT INTERRUPTED *****"
|
||||
$ExitCode = 255
|
||||
Exit-Function
|
||||
}
|
||||
#----------
|
||||
|
||||
|
||||
|
||||
|
||||
#----------
|
||||
try {
|
||||
$ErrorRecord = [System.Management.Automation.ErrorRecord] $InputObject
|
||||
try {
|
||||
$ErrorRecord = [System.Management.Automation.ErrorRecord] $InputObject
|
||||
<#
|
||||
$ExitString = @"
|
||||
$($ErrorRecord.ToString())
|
||||
|
@ -89,38 +89,38 @@ $($ErrorRecord.ScriptStackTrace.ToString())
|
|||
$ExitString = Out-String -InputObject $InputObject
|
||||
$ExitCode = 255
|
||||
Exit-Function
|
||||
}
|
||||
catch {
|
||||
$ErrorRecord = $null
|
||||
Write-LogWarning "Unable to cast InputObject to [System.Management.Automation.ErrorRecord]"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$ErrorRecord = $null
|
||||
Write-LogWarning "Unable to cast InputObject to [System.Management.Automation.ErrorRecord]"
|
||||
}
|
||||
#----------
|
||||
|
||||
|
||||
|
||||
|
||||
#----------
|
||||
try {
|
||||
$Exception = [System.Exception] $InputObject
|
||||
#$ExitString = $Exception.ToString()
|
||||
try {
|
||||
$Exception = [System.Exception] $InputObject
|
||||
#$ExitString = $Exception.ToString()
|
||||
$ExitString = Out-String -InputObject $InputObject
|
||||
$ExitCode = 255
|
||||
Exit-Function
|
||||
}
|
||||
catch {
|
||||
$Exception = $null
|
||||
Write-LogWarning "Unable to cast InputObject to [System.Exception]"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$Exception = $null
|
||||
Write-LogWarning "Unable to cast InputObject to [System.Exception]"
|
||||
}
|
||||
#----------
|
||||
|
||||
|
||||
|
||||
#----------
|
||||
try {
|
||||
$ExitString = Out-String -InputObject $InputObject
|
||||
try {
|
||||
$ExitString = Out-String -InputObject $InputObject
|
||||
$ExitCode = 255
|
||||
Exit-Function
|
||||
}
|
||||
catch {
|
||||
Write-LogWarning "Unable to cast InputObject of type [$($InputObject.GetType())] to any of supported types."
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-LogWarning "Unable to cast InputObject of type [$($InputObject.GetType())] to any of supported types."
|
||||
}
|
||||
#----------
|
||||
}
|
||||
"ErrorString" {
|
||||
|
@ -128,11 +128,11 @@ $($ErrorRecord.ScriptStackTrace.ToString())
|
|||
$ExitString = "Script stopped with NO ERROR."
|
||||
$ExitCode = 0
|
||||
}
|
||||
|
||||
|
||||
Exit-Function
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ExitString = "Unknown error occured in Stop-Execution"
|
||||
$ExitCode = 255
|
||||
Exit-Function
|
||||
|
@ -150,7 +150,7 @@ Convert to / request password as secure string.
|
|||
[String] $Password = "",
|
||||
[String] $Prompt = "Please enter password"
|
||||
)
|
||||
|
||||
|
||||
if ($Password -eq "") {
|
||||
Read-Host -Prompt $Prompt -AsSecureString
|
||||
}
|
||||
|
@ -167,15 +167,15 @@ Function New-Credential {
|
|||
Create new creadential object with username and password provided.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[String] $UserName,
|
||||
|
||||
[String] $Password
|
||||
)
|
||||
|
||||
$SecurePassword = Get-PasswordAsSecureString -Password "$Password"
|
||||
New-Object System.Management.Automation.PSCredential( "$UserName", $SecurePassword )
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[String] $UserName,
|
||||
|
||||
[String] $Password
|
||||
)
|
||||
|
||||
$SecurePassword = Get-PasswordAsSecureString -Password "$Password"
|
||||
New-Object System.Management.Automation.PSCredential( "$UserName", $SecurePassword )
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,8 +199,8 @@ public static extern IntPtr SendMessageTimeout(
|
|||
Write-Log "Executing 'SendMessageTimeout' ..."
|
||||
|
||||
$retval = [Win32.NativeMethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE,
|
||||
[UIntPtr]::Zero, "Environment", 2, 5000, [ref] $result)
|
||||
|
||||
[UIntPtr]::Zero, "Environment", 2, 5000, [ref] $result)
|
||||
|
||||
Write-Log "'SendMessageTimeout' returned '$retval' (non-zero is OK)"
|
||||
}
|
||||
|
||||
|
@ -292,8 +292,8 @@ Function Start-Program {
|
|||
}
|
||||
|
||||
$Result.ExitCode = $Process.ExitCode
|
||||
$Result.StdOut = $Result.StdOut - split "`r`n"
|
||||
$Result.StdErr = $Result.StdErr - split "`r`n"
|
||||
$Result.StdOut = $Result.StdOut -split "`r`n"
|
||||
$Result.StdErr = $Result.StdErr -split "`r`n"
|
||||
$Process = $null
|
||||
|
||||
if ($RedirectStreams) {
|
||||
|
@ -325,12 +325,12 @@ Function Backup-File {
|
|||
)
|
||||
|
||||
$BackupFile = "$Path.bak"
|
||||
|
||||
|
||||
if (-not [IO.File]::Exists($Path)) {
|
||||
Write-LogError "Unable to backup file '$Path': file not exists."
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if ([IO.File]::Exists($BackupFile)) {
|
||||
try {
|
||||
[IO.File]::Delete($BackupFile)
|
||||
|
@ -362,20 +362,20 @@ Function Install-Module {
|
|||
$ModuleName = $ModulePath.Split("\")[-1]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($InstallPath -eq "") {
|
||||
Stop-Execution -ExitString "To install the module destination path must be provided."
|
||||
}
|
||||
else {
|
||||
Write-Log "Installing the module to '$InstallPath'"
|
||||
|
||||
|
||||
$NewModulePath = [IO.Path]::Combine($InstallPath, $ModuleName)
|
||||
if ([IO.Directory]::Exists($NewModulePath)) {
|
||||
[IO.Directory]::Delete($NewModulePath, $true)
|
||||
}
|
||||
|
||||
|
||||
Copy-Item -Path $ModulePath -Destination $InstallPath -Recurse -Force -ErrorAction Stop
|
||||
|
||||
|
||||
Update-PsModulePath -AddPath "$InstallPath"
|
||||
}
|
||||
}
|
||||
|
@ -412,12 +412,12 @@ Returned values:
|
|||
)
|
||||
|
||||
$ModuleVersion = (Get-Module -Name $Name -ListAvailable).Version
|
||||
|
||||
|
||||
if ($ModuleVersion -eq $null) {
|
||||
Write-Log "Module '$Name' not found."
|
||||
return -2
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$RequiredVersion = [System.Version]::Parse($Version)
|
||||
}
|
||||
|
@ -425,6 +425,6 @@ Returned values:
|
|||
Write-Log "'$Version' is not a correct version string."
|
||||
return -2
|
||||
}
|
||||
|
||||
|
||||
$ModuleVersion.CompareTo($RequiredVersion)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
Function Initialize-Logger {
|
||||
Function Initialize-Logger {
|
||||
param (
|
||||
[String] $ModuleName = $__ModuleName,
|
||||
[String] $LogPath = $__DefaultLogPath
|
||||
)
|
||||
|
||||
|
||||
if (-not ("log4net.LogManager" -as [type])) {
|
||||
$FileStream = ([System.IO.FileInfo] (Get-Item "$__ModulePath\log4net.dll")).OpenRead()
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
$Log4NetConfig = New-Object System.IO.FileInfo("$__ModulePath\log4net.config")
|
||||
|
||||
[log4net.Config.XmlConfigurator]::Configure($Log4NetConfig)
|
||||
|
||||
|
||||
$__Logger.info("Logger initialized. Log file: '$LogPath'`n")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
Function Set-LocalUserPassword {
|
||||
Function Set-LocalUserPassword {
|
||||
param (
|
||||
[String] $UserName,
|
||||
[String] $Password,
|
||||
[Switch] $Force
|
||||
)
|
||||
|
||||
|
||||
trap { Stop-Execution $_ }
|
||||
|
||||
|
||||
if ((Get-WmiObject Win32_UserAccount -Filter "LocalAccount = 'True' AND Name='$UserName'") -eq $null) {
|
||||
throw "Unable to find local user account '$UserName'"
|
||||
}
|
||||
|
||||
|
||||
if ($Force) {
|
||||
Write-Log "Changing password for user '$UserName' to '*****'" # :)
|
||||
([ADSI] "WinNT://./$UserName").SetPassword($Password) | Out-Null
|
||||
|
@ -23,30 +23,30 @@
|
|||
|
||||
|
||||
Function Set-AutoLogonCredentials {
|
||||
param (
|
||||
[String] $DomainName,
|
||||
[String] $UserName,
|
||||
[String] $Password
|
||||
)
|
||||
|
||||
$KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
|
||||
param (
|
||||
[String] $DomainName,
|
||||
[String] $UserName,
|
||||
[String] $Password
|
||||
)
|
||||
|
||||
$KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
|
||||
|
||||
if ($DomainName -ne "") {
|
||||
$UserName = "$DomainName\$UserName"
|
||||
}
|
||||
|
||||
if ($DomainName -ne "") {
|
||||
$UserName = "$DomainName\$UserName"
|
||||
}
|
||||
|
||||
Write-Log "Setting AutoLogon credentials ..."
|
||||
try {
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultUserName", "$UserName", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultPassword", "$Password", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "AutoAdminLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "ForceAutoLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
try {
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultUserName", "$UserName", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultPassword", "$Password", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "AutoAdminLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
[Microsoft.Win32.Registry]::SetValue($KeyName, "ForceAutoLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
|
||||
}
|
||||
catch {
|
||||
Write-LogError "FAILED"
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Write-Log "SUCCESS"
|
||||
}
|
||||
|
||||
|
@ -59,16 +59,16 @@ Function Expand-Template {
|
|||
[System.Collections.Hashtable] $ReplacementList,
|
||||
[String] $Encoding = "Ascii"
|
||||
)
|
||||
|
||||
|
||||
if (-not [IO.File]::Exists($TemplateFile)) {
|
||||
Write-Error "File '$TemplateFile' not exists"
|
||||
return $null
|
||||
}
|
||||
|
||||
|
||||
if ([IO.File]::Exists($OutputFile)) {
|
||||
[IO.File]::Delete($OutputFile)
|
||||
}
|
||||
|
||||
|
||||
Get-Content $TemplateFile -Encoding $Encoding |
|
||||
ForEach-Object {
|
||||
$Line = $_
|
||||
|
@ -93,35 +93,35 @@ It fails if any of required features fails.
|
|||
|
||||
It reports that reboot required if it is required, or restarts the computer.
|
||||
#>
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[String[]] $Name,
|
||||
[Switch] $IncludeManagementTools,
|
||||
[Switch] $AllowRestart,
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[String[]] $Name,
|
||||
[Switch] $IncludeManagementTools,
|
||||
[Switch] $AllowRestart,
|
||||
[Switch] $NotifyRestart
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
$RestartNeeded = $false
|
||||
|
||||
foreach ($Feature in $Name) {
|
||||
Write-Log "Installing feature '$Feature' ..."
|
||||
$Action = Install-WindowsFeature `
|
||||
-Name $Feature `
|
||||
-IncludeManagementTools:$IncludeManagementTools `
|
||||
-ErrorAction Stop
|
||||
|
||||
if ($Action.Success -eq $true) {
|
||||
if ($Action.FeatureResult.RestartNeeded -eq $true) {
|
||||
Write-LogWarning "Restart required"
|
||||
$RestartNeeded = $true
|
||||
}
|
||||
Write-Log "Feature '$Feature' installed successfully"
|
||||
}
|
||||
else {
|
||||
Stop-Execution "Failed to install feature '$Feature'"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($Feature in $Name) {
|
||||
Write-Log "Installing feature '$Feature' ..."
|
||||
$Action = Install-WindowsFeature `
|
||||
-Name $Feature `
|
||||
-IncludeManagementTools:$IncludeManagementTools `
|
||||
-ErrorAction Stop
|
||||
|
||||
if ($Action.Success -eq $true) {
|
||||
if ($Action.FeatureResult.RestartNeeded -eq $true) {
|
||||
Write-LogWarning "Restart required"
|
||||
$RestartNeeded = $true
|
||||
}
|
||||
Write-Log "Feature '$Feature' installed successfully"
|
||||
}
|
||||
else {
|
||||
Stop-Execution "Failed to install feature '$Feature'"
|
||||
}
|
||||
}
|
||||
|
||||
if ($RestartNeeded) {
|
||||
Write-Log "Restart required to finish feature(s) installation."
|
||||
if ($AllowRestart) {
|
||||
|
@ -148,25 +148,25 @@ This funciton checks if ReturnValue property is equal to 0.
|
|||
If it is not, then funtion should try to provide desctiption for the error code based on the WMI object type.
|
||||
WMI object type must be provided explicitely.
|
||||
#>
|
||||
param (
|
||||
[Parameter(ValueFromPipeline=$true,Mandatory=$true)]
|
||||
$InputObject,
|
||||
[String] $Type = ""
|
||||
)
|
||||
|
||||
try {
|
||||
$ReturnValue = $InputObject.ReturnValue
|
||||
}
|
||||
catch {
|
||||
throw "Property 'ReturnValue' not found on this object"
|
||||
}
|
||||
|
||||
if ($ReturnValue -eq 0) {
|
||||
Write-Log "WMI operation completed successfully"
|
||||
}
|
||||
else {
|
||||
throw "Operation failed with status code = $ReturnValue"
|
||||
}
|
||||
param (
|
||||
[Parameter(ValueFromPipeline=$true,Mandatory=$true)]
|
||||
$InputObject,
|
||||
[String] $Type = ""
|
||||
)
|
||||
|
||||
try {
|
||||
$ReturnValue = $InputObject.ReturnValue
|
||||
}
|
||||
catch {
|
||||
throw "Property 'ReturnValue' not found on this object"
|
||||
}
|
||||
|
||||
if ($ReturnValue -eq 0) {
|
||||
Write-Log "WMI operation completed successfully"
|
||||
}
|
||||
else {
|
||||
throw "Operation failed with status code = $ReturnValue"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -190,142 +190,142 @@ PS> Set-NetworkAdapterConfiguration -MACAddress aa:bb:cc:dd:ee:ff -DNSServer "19
|
|||
Configure DNS servers list for network adapter with MAC address aa:bb:cc:dd:ee:ff
|
||||
|
||||
#>
|
||||
param (
|
||||
[String] $MACAddress = "",
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String] $IPAddress = "",
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String] $IPNetmask = "",
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String[]] $IPGateway = @(),
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String[]] $DNSServer = @(),
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[Switch] $FirstAvailable,
|
||||
param (
|
||||
[String] $MACAddress = "",
|
||||
|
||||
[String] $Name = "",
|
||||
|
||||
[Parameter(ParameterSetName="AutoConfig",Mandatory=$true)]
|
||||
[Switch] $Auto,
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String] $IPAddress = "",
|
||||
|
||||
[Parameter(ParameterSetName="AutoConfig")]
|
||||
[Switch] $All
|
||||
)
|
||||
|
||||
Write-Log "Configuring network adapter(s) ..."
|
||||
|
||||
:SetIPAddress switch($PSCmdlet.ParameterSetName) {
|
||||
"AutoConfig" {
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String] $IPNetmask = "",
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String[]] $IPGateway = @(),
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[String[]] $DNSServer = @(),
|
||||
|
||||
[Parameter(ParameterSetName="ManualConfig")]
|
||||
[Switch] $FirstAvailable,
|
||||
|
||||
[String] $Name = "",
|
||||
|
||||
[Parameter(ParameterSetName="AutoConfig",Mandatory=$true)]
|
||||
[Switch] $Auto,
|
||||
|
||||
[Parameter(ParameterSetName="AutoConfig")]
|
||||
[Switch] $All
|
||||
)
|
||||
|
||||
Write-Log "Configuring network adapter(s) ..."
|
||||
|
||||
:SetIPAddress switch($PSCmdlet.ParameterSetName) {
|
||||
"AutoConfig" {
|
||||
Write-Log "'auto' mode"
|
||||
|
||||
$IPv4RegExp = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
|
||||
|
||||
if ($All -eq $true) {
|
||||
$Filter = { $_.AdapterTypeId -eq 0 }
|
||||
$Name = ""
|
||||
}
|
||||
else {
|
||||
$Filter = { $_.MACAddress -eq $MACAddress }
|
||||
}
|
||||
|
||||
Get-WmiObject Win32_NetworkAdapter |
|
||||
Where-Object $Filter |
|
||||
ForEach-Object {
|
||||
$NetworkAdapter = $_
|
||||
$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
|
||||
Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
|
||||
|
||||
Write-Log "Configuring '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++) {
|
||||
if ($AdapterConfig.IPAddress[$i] -match $IPv4RegExp) {
|
||||
$IPAddress = $AdapterConfig.IPAddress[$i]
|
||||
$IPNetmask = $AdapterConfig.IPSubnet[$i]
|
||||
$IPGateway = $AdapterConfig.DefaultIPGateway
|
||||
|
||||
$IPv4RegExp = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
|
||||
|
||||
if ($All -eq $true) {
|
||||
$Filter = { $_.AdapterTypeId -eq 0 }
|
||||
$Name = ""
|
||||
}
|
||||
else {
|
||||
$Filter = { $_.MACAddress -eq $MACAddress }
|
||||
}
|
||||
|
||||
Get-WmiObject Win32_NetworkAdapter |
|
||||
Where-Object $Filter |
|
||||
ForEach-Object {
|
||||
$NetworkAdapter = $_
|
||||
$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
|
||||
Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
|
||||
|
||||
Write-Log "Configuring '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++) {
|
||||
if ($AdapterConfig.IPAddress[$i] -match $IPv4RegExp) {
|
||||
$IPAddress = $AdapterConfig.IPAddress[$i]
|
||||
$IPNetmask = $AdapterConfig.IPSubnet[$i]
|
||||
$IPGateway = $AdapterConfig.DefaultIPGateway
|
||||
$DNSServer = $AdapterConfig.DNSServerSearchOrder
|
||||
|
||||
Write-Log "Setting IP address ($IPAddress), netmask ($IPNetmask) ..."
|
||||
$AdapterConfig.EnableStatic($IPAddress, $IPNetmask) | Out-Null
|
||||
|
||||
|
||||
Write-Log "Setting IP address ($IPAddress), netmask ($IPNetmask) ..."
|
||||
$AdapterConfig.EnableStatic($IPAddress, $IPNetmask) | Out-Null
|
||||
|
||||
Write-Log "Setting default gateways ($IPGateway) ..."
|
||||
$AdapterConfig.SetGateways($IPGateway) | Out-Null
|
||||
|
||||
$AdapterConfig.SetGateways($IPGateway) | Out-Null
|
||||
|
||||
Write-Log "Setting DNS servers ($DNSServer) ..."
|
||||
$AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Write-Log "'$($NetworkAdapter.Name)' configured"
|
||||
}
|
||||
}
|
||||
"ManualConfig" {
|
||||
}
|
||||
}
|
||||
"ManualConfig" {
|
||||
Write-Log "'manual' mode"
|
||||
if ( $FirstAvailable ) {
|
||||
if ( $FirstAvailable ) {
|
||||
Write-Log "Selecting first available network adapter ..."
|
||||
$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
|
||||
Where-Object { $_.AdapterTypeId -eq 0 } |
|
||||
Select-Object -First 1
|
||||
}
|
||||
else {
|
||||
$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
|
||||
Where-Object { $_.MACAddress -eq $MACAddress }
|
||||
}
|
||||
|
||||
if ( $NetworkAdapter -eq $null ) {
|
||||
Write-LogError "Network adapter with MAC = '$MACAddress' not found."
|
||||
return
|
||||
}
|
||||
|
||||
$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
|
||||
Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
|
||||
$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
|
||||
Where-Object { $_.AdapterTypeId -eq 0 } |
|
||||
Select-Object -First 1
|
||||
}
|
||||
else {
|
||||
$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
|
||||
Where-Object { $_.MACAddress -eq $MACAddress }
|
||||
}
|
||||
|
||||
if (($IPAddress -ne "") -and ($IPNetmask -ne "")) {
|
||||
Write-Log "Configuring IP address / netmask for '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
<#
|
||||
for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++)
|
||||
{
|
||||
if (($AdapterConfig.IPAddress[$i] -eq $IPAddress) -and ($AdapterConfig.IPSubnet[$i] -eq $IPNetmask))
|
||||
{
|
||||
Write-Log "There is an adapter with required configuration."
|
||||
break SetIPAddress
|
||||
}
|
||||
}
|
||||
#>
|
||||
Write-Log "Setting IP address $IPAddress, netmask $IPNetmask"
|
||||
$AdapterConfig.EnableStatic("$IPAddress", "$IPNetmask") | Out-Null
|
||||
|
||||
Write-Log "IP address configured."
|
||||
}
|
||||
|
||||
if ($IPGateway.Count -gt 0) {
|
||||
Write-Log "Configuring IP gateway for '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
$AdapterConfig.SetGateways($IPGateway) | Out-Null
|
||||
|
||||
Write-Log "IP gateway configured."
|
||||
}
|
||||
|
||||
if ($DNSServer.Count -gt 0) {
|
||||
Write-Log "Configuring DNS server(s) for '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
$AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
|
||||
|
||||
Write-Log "DNS configured."
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $NetworkAdapter -eq $null ) {
|
||||
Write-LogError "Network adapter with MAC = '$MACAddress' not found."
|
||||
return
|
||||
}
|
||||
|
||||
if ($Name -ne "") {
|
||||
Write-Log "Changing adapter name '$($NetworkAdapter.NetConnectionId)' --> '$Name'"
|
||||
$NetworkAdapter.NetConnectionId = "$Name"
|
||||
$NetworkAdapter.Put() | Out-Null
|
||||
}
|
||||
$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
|
||||
Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
|
||||
|
||||
if (($IPAddress -ne "") -and ($IPNetmask -ne "")) {
|
||||
Write-Log "Configuring IP address / netmask for '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
<#
|
||||
for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++)
|
||||
{
|
||||
if (($AdapterConfig.IPAddress[$i] -eq $IPAddress) -and ($AdapterConfig.IPSubnet[$i] -eq $IPNetmask))
|
||||
{
|
||||
Write-Log "There is an adapter with required configuration."
|
||||
break SetIPAddress
|
||||
}
|
||||
}
|
||||
#>
|
||||
Write-Log "Setting IP address $IPAddress, netmask $IPNetmask"
|
||||
$AdapterConfig.EnableStatic("$IPAddress", "$IPNetmask") | Out-Null
|
||||
|
||||
Write-Log "IP address configured."
|
||||
}
|
||||
|
||||
if ($IPGateway.Count -gt 0) {
|
||||
Write-Log "Configuring IP gateway for '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
$AdapterConfig.SetGateways($IPGateway) | Out-Null
|
||||
|
||||
Write-Log "IP gateway configured."
|
||||
}
|
||||
|
||||
if ($DNSServer.Count -gt 0) {
|
||||
Write-Log "Configuring DNS server(s) for '$($NetworkAdapter.Name)' ..."
|
||||
|
||||
$AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
|
||||
|
||||
Write-Log "DNS configured."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($Name -ne "") {
|
||||
Write-Log "Changing adapter name '$($NetworkAdapter.NetConnectionId)' --> '$Name'"
|
||||
$NetworkAdapter.NetConnectionId = "$Name"
|
||||
$NetworkAdapter.Put() | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -352,36 +352,36 @@ Function tests the following conditions:
|
|||
Multiple checks are logically ANDed.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[String] $ComputerName,
|
||||
[String] $DomainName,
|
||||
[String] $WorkgroupName,
|
||||
[Switch] $PartOfDomain
|
||||
)
|
||||
process {
|
||||
$ComputerSystem = Get-WmiObject Win32_ComputerSystem
|
||||
|
||||
if (($ComputerName -ne "") -and ($ComputerSystem.Name -ne "$ComputerName")) {
|
||||
param (
|
||||
[String] $ComputerName,
|
||||
[String] $DomainName,
|
||||
[String] $WorkgroupName,
|
||||
[Switch] $PartOfDomain
|
||||
)
|
||||
process {
|
||||
$ComputerSystem = Get-WmiObject Win32_ComputerSystem
|
||||
|
||||
if (($ComputerName -ne "") -and ($ComputerSystem.Name -ne "$ComputerName")) {
|
||||
Write-Error "ComputerName is not equal to '$ComputerName'"
|
||||
return $false
|
||||
}
|
||||
|
||||
if (($DomainName -ne "") -and ($ComputerSystem.Domain -ne "$DomainName")) {
|
||||
return $false
|
||||
}
|
||||
|
||||
if (($DomainName -ne "") -and ($ComputerSystem.Domain -ne "$DomainName")) {
|
||||
Write-Error "DomainName is not equal to '$DomainName'"
|
||||
return $false
|
||||
}
|
||||
|
||||
if (($WorkgroupName -ne "") -and ($ComputerSystem.Workgroup -ne "$WorkgroupName")) {
|
||||
return $false
|
||||
}
|
||||
|
||||
if (($WorkgroupName -ne "") -and ($ComputerSystem.Workgroup -ne "$WorkgroupName")) {
|
||||
Write-Error "WorkgroupName is not equal to '$WorkgroupName'"
|
||||
return $false
|
||||
}
|
||||
|
||||
if (($PartOfDOmain -eq $true) -and ($ComputerSystem.PartOfDomain -eq $false)) {
|
||||
return $false
|
||||
}
|
||||
|
||||
if (($PartOfDOmain -eq $true) -and ($ComputerSystem.PartOfDomain -eq $false)) {
|
||||
Write-Error "Computer is not the part of any domain."
|
||||
return $false
|
||||
}
|
||||
|
||||
return $true
|
||||
return $false
|
||||
}
|
||||
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,21 +391,21 @@ Function Set-ComputerName {
|
|||
param (
|
||||
[String] $Name
|
||||
)
|
||||
|
||||
|
||||
# Rename the computer
|
||||
if ($Name -ne "") {
|
||||
if (Test-ComputerName -ComputerName $Name) {
|
||||
Stop-Execution -Success -ExitString "Computer name already configured"
|
||||
}
|
||||
else {
|
||||
Write-Log "Renaming computer to '$Name'"
|
||||
|
||||
Rename-Computer -NewName $NewName -Force -ErrorAction Stop
|
||||
|
||||
Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now"
|
||||
}
|
||||
}
|
||||
|
||||
# Rename the computer
|
||||
if ($Name -ne "") {
|
||||
if (Test-ComputerName -ComputerName $Name) {
|
||||
Stop-Execution -Success -ExitString "Computer name already configured"
|
||||
}
|
||||
else {
|
||||
Write-Log "Renaming computer to '$Name'"
|
||||
|
||||
Rename-Computer -NewName $NewName -Force -ErrorAction Stop
|
||||
|
||||
Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -415,7 +415,7 @@ Function Resolve-LdapDnsName {
|
|||
param (
|
||||
[String] $DomainName
|
||||
)
|
||||
|
||||
|
||||
Resolve-DNSName -Type "SRV" -Name "_ldap._tcp.dc._msdcs.$DomainName" |
|
||||
Where-Object { $_.Type -eq "A" } |
|
||||
Select-Object -Property Name,IPAddress
|
||||
|
@ -429,10 +429,10 @@ Function Wait-LdapServerAvailable {
|
|||
[Int] $PingSeqCountThreshold = 10,
|
||||
[Int] $PingSeqPerHostThreshold = 5
|
||||
)
|
||||
|
||||
|
||||
$LdapServerList = @( Resolve-LdapDnsName $DomainName )
|
||||
Write-Log @( "Ldap server list:", ( $LdapServerList | Out-String ) )
|
||||
|
||||
|
||||
:MainLoop foreach ($LdapServer in $LdapServerList) {
|
||||
$PingSeqCount = 0
|
||||
$PingSeqPerHost = 0
|
||||
|
@ -446,16 +446,16 @@ Function Wait-LdapServerAvailable {
|
|||
$PingSeqCount = 0
|
||||
$PingSeqPerHost++
|
||||
}
|
||||
|
||||
|
||||
if ($PingSeqCount -ge $PingSeqCountThreshold) {
|
||||
Write-Log "Returning true"
|
||||
return $true
|
||||
}
|
||||
|
||||
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Write-Log "Returning false"
|
||||
return $false
|
||||
}
|
||||
|
@ -467,18 +467,18 @@ Function Get-ConfigDriveObject {
|
|||
param (
|
||||
[Parameter(ParameterSetName="MetaData")]
|
||||
[Switch] $MetaData,
|
||||
|
||||
|
||||
[Parameter(ParameterSetName="UserData")]
|
||||
[Switch] $UserData,
|
||||
|
||||
|
||||
[Parameter(ParameterSetName="CustomObject")]
|
||||
[String] $CustomObject,
|
||||
|
||||
|
||||
[String] $Path = "openstack/latest"
|
||||
)
|
||||
|
||||
|
||||
$ConfigDrivePrefix = "http://169.254.169.154/$Path"
|
||||
|
||||
|
||||
try {
|
||||
switch($PSCmdlet.ParameterSetName) {
|
||||
"MetaData" {
|
||||
|
@ -510,7 +510,7 @@ Function Update-AgentConfig {
|
|||
param (
|
||||
[String] $RootPath = "C:\Murano\Agent"
|
||||
)
|
||||
|
||||
|
||||
try {
|
||||
$MetaData = Get-ConfigDriveObject -MetaData -ErrorAction Stop
|
||||
if ($MetaData.meta -ne $null) {
|
||||
|
@ -535,9 +535,9 @@ Function Update-PsModulePath {
|
|||
@([Environment]::GetEnvironmentVariable("PsModulePath", [EnvironmentVariableTarget]::Machine) -split ";") + @($AddPath) `
|
||||
| Select-Object -Unique
|
||||
) -join ';'
|
||||
|
||||
|
||||
[Environment]::SetEnvironmentVariable("PsModulePath", $NewPsModulePath, [EnvironmentVariableTarget]::Machine)
|
||||
|
||||
|
||||
Invoke-WMSettingsChange
|
||||
}
|
||||
|
||||
|
@ -550,39 +550,39 @@ Function Get-ModuleHelp {
|
|||
[Switch] $File,
|
||||
[Int] $Width = 80
|
||||
)
|
||||
|
||||
$sb = {
|
||||
|
||||
$sb = {
|
||||
$Module = Get-Module $ModuleName
|
||||
|
||||
"`n"
|
||||
|
||||
"`n"
|
||||
"Module: $($Module.Name)"
|
||||
"Module version: $($Module.Version)"
|
||||
"`n"
|
||||
"Module version: $($Module.Version)"
|
||||
"`n"
|
||||
"{0} Module Description {0}" -f ('=' * 30)
|
||||
"`n"
|
||||
|
||||
Get-Help "about_$($Module.Name)" | Out-String -Width $Width
|
||||
|
||||
|
||||
Get-Help "about_$($Module.Name)" | Out-String -Width $Width
|
||||
|
||||
"{0} Exported Functions {0}" -f ('=' * 30)
|
||||
"`n"
|
||||
|
||||
foreach ($CommandName in $Module.ExportedCommands.Keys) {
|
||||
|
||||
foreach ($CommandName in $Module.ExportedCommands.Keys) {
|
||||
'-' * 80
|
||||
Get-Help -Name $CommandName -Detailed | Out-String -Width $Width
|
||||
}
|
||||
Get-Help -Name $CommandName -Detailed | Out-String -Width $Width
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($File) -and ($Path -eq "")) {
|
||||
$Path = [IO.Path]::GetTempFileName()
|
||||
}
|
||||
|
||||
|
||||
if ($Path -ne "") {
|
||||
& $sb | Out-File -FilePath $Path -Force
|
||||
}
|
||||
else {
|
||||
& $sb | Out-Default
|
||||
}
|
||||
|
||||
|
||||
if ($File) {
|
||||
notepad.exe "$Path"
|
||||
}
|
||||
|
@ -594,9 +594,9 @@ Function New-ModuleTemplate {
|
|||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[String] $Name,
|
||||
|
||||
|
||||
[String] $Path = "$($Env:USERPROFILE)\Documents\WindowsPowerShell\Modules",
|
||||
|
||||
|
||||
[Switch] $Force
|
||||
)
|
||||
if ([IO.Directory]::Exists("$Path\$Name")) {
|
||||
|
@ -608,26 +608,26 @@ Function New-ModuleTemplate {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[IO.Directory]::CreateDirectory("$Path\$Name")
|
||||
[IO.Directory]::CreateDirectory("$Path\$Name\en-US")
|
||||
[IO.Directory]::CreateDirectory("$Path\$Name\include")
|
||||
|
||||
|
||||
|
||||
|
||||
Set-Content -Path "$Path\$Name\en-US\about_$Name.help.txt" -Value @'
|
||||
'@
|
||||
|
||||
|
||||
|
||||
Set-Content -Path "$Path\$Name\Config.ps1" -Value @'
|
||||
$script:__ModulePath = $PsScriptRoot
|
||||
$script:__ModuleName = $PsScriptRoot.Split("\")[-1]
|
||||
$script:__DefaultLogPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), "PowerShell_$__ModuleName.log")
|
||||
|
||||
$global:__StopExecutionExitsSession__ = $false
|
||||
'@
|
||||
|
||||
|
||||
'@
|
||||
|
||||
|
||||
Set-Content -Path "$Path\$Name\$Name.psm1" -Value @'
|
||||
# Import config first
|
||||
. "$PsScriptRoot\Config.ps1"
|
||||
|
@ -644,13 +644,13 @@ Initialize-Logger -ModuleName $__ModuleName -LogPath $__DefaultLogPath
|
|||
|
||||
Write-Log "Module loaded from '$PsScriptRoot'"
|
||||
'@
|
||||
|
||||
|
||||
|
||||
|
||||
New-ModuleManifest `
|
||||
-Path "$Path\$Name\$Name.psd1" `
|
||||
-ModuleToProcess "$Name.psm1" `
|
||||
-RequiredModules "CoreFunctions"
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -668,14 +668,14 @@ function New-SqlServerConnection {
|
|||
if ($UserName -eq '') {
|
||||
throw "User name must be provided in order to create credentials object!"
|
||||
}
|
||||
|
||||
|
||||
$Credentials = New-Credential -UserName $UserName -Password $Password
|
||||
}
|
||||
|
||||
$Server = New-Object `
|
||||
-TypeName Microsoft.SqlServer.Management.Smo.Server `
|
||||
-ArgumentList $ServerName
|
||||
|
||||
|
||||
$LoginName = $Credentials.UserName -replace("^\\", "")
|
||||
|
||||
try {
|
||||
|
@ -733,7 +733,7 @@ http://msdn.microsoft.com/en-us/library/cc281962%28v=sql.105%29.aspx
|
|||
"Microsoft.SqlServer.Smo"
|
||||
"Microsoft.SqlServer.SmoExtended"
|
||||
)
|
||||
|
||||
|
||||
foreach ($asm in $AssemblyList) {
|
||||
[System.Reflection.Assembly]::LoadWithPartialName($asm) | Out-Null
|
||||
}
|
||||
|
@ -765,13 +765,13 @@ function Import-SqlServerProvider {
|
|||
#
|
||||
Push-Location
|
||||
Set-Location $sqlpsPath
|
||||
|
||||
|
||||
Add-PSSnapin SqlServerCmdletSnapin100
|
||||
Add-PSSnapin SqlServerProviderSnapin100
|
||||
|
||||
Update-TypeData -PrependPath SQLProvider.Types.ps1xml
|
||||
Update-FormatData -PrependPath SQLProvider.Format.ps1xml
|
||||
|
||||
|
||||
Update-TypeData -PrependPath SQLProvider.Types.ps1xml
|
||||
Update-FormatData -PrependPath SQLProvider.Format.ps1xml
|
||||
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
|
|
|
@ -10,25 +10,25 @@ Function Compress-Folder {
|
|||
[String] $Path,
|
||||
|
||||
[String] $ZipFile = "",
|
||||
|
||||
|
||||
[Switch] $TempFile,
|
||||
|
||||
|
||||
[Switch] $ContentOnly
|
||||
)
|
||||
|
||||
|
||||
if (-not [IO.Directory]::Exists($Path)) {
|
||||
Write-LogError "Directory '$Path' not found."
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if ($TempFile) {
|
||||
$ZipFile = [IO.Path]::GetTempFileName()
|
||||
}
|
||||
|
||||
|
||||
if ($ZipFile -eq "") {
|
||||
$ZipFile = "$Path.zip"
|
||||
}
|
||||
|
||||
|
||||
if ([IO.File]::Exists($ZipFile)) {
|
||||
[IO.File]::Delete($ZipFile)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ Function Compress-Folder {
|
|||
}
|
||||
$zip.Save($ZipFile)
|
||||
$zip.Dispose()
|
||||
|
||||
|
||||
return $ZipFile
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ Function Expand-Zip {
|
|||
|
||||
[String] $Destination
|
||||
)
|
||||
|
||||
|
||||
if (-not [IO.File]::Exists($Path)) {
|
||||
Write-LogError "File not found '$Path'"
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
$zip = [Ionic.Zip.ZipFile]::Read($Path)
|
||||
$zip.ExtractAll($Destination, [Ionic.Zip.ExtractExistingFileAction]::OverwriteSilently)
|
||||
$zip.Dispose()
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
<log4net>
|
||||
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
|
||||
<param name="File" type="log4net.Util.PatternString" value="%property{LogPath}" />
|
||||
<param name="AppendToFile" value="true" />
|
||||
<param name="RollingStyle" value="Size" />
|
||||
<param name="MaxSizeRollBackups" value="100" />
|
||||
<param name="MaximumFileSize" value="1024KB" />
|
||||
<param name="StaticLogFileName" value="true" />
|
||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="ConversionPattern" value="%date [%-5level] [%property{ModuleName}] %message" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
|
||||
<mapping>
|
||||
<level value="error" />
|
||||
<foreColor value="Red, HighIntensity" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="warn" />
|
||||
<foreColor value="Yellow, HighIntensity" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="info" />
|
||||
<foreColor value="Green, HighIntensity" />
|
||||
</mapping>
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date [%-5level] [%property{ModuleName}] %message" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
|
||||
<param name="File" type="log4net.Util.PatternString" value="%property{LogPath}" />
|
||||
<param name="AppendToFile" value="true" />
|
||||
<param name="RollingStyle" value="Size" />
|
||||
<param name="MaxSizeRollBackups" value="100" />
|
||||
<param name="MaximumFileSize" value="1024KB" />
|
||||
<param name="StaticLogFileName" value="true" />
|
||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="ConversionPattern" value="%date [%-5level] [%property{ModuleName}] %message" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!--root>
|
||||
<level value="info" />
|
||||
</root-->
|
||||
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
|
||||
<mapping>
|
||||
<level value="error" />
|
||||
<foreColor value="Red, HighIntensity" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="warn" />
|
||||
<foreColor value="Yellow, HighIntensity" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="info" />
|
||||
<foreColor value="Green, HighIntensity" />
|
||||
</mapping>
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date [%-5level] [%property{ModuleName}] %message" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<logger name="PowerShell" additivity="false">
|
||||
<!--level value="info" /-->
|
||||
<appender-ref ref="ColoredConsoleAppender" />
|
||||
<appender-ref ref="RollingFileAppender" />
|
||||
</logger>
|
||||
<!--root>
|
||||
<level value="info" />
|
||||
</root-->
|
||||
|
||||
<logger name="PowerShell" additivity="false">
|
||||
<!--level value="info" /-->
|
||||
<appender-ref ref="ColoredConsoleAppender" />
|
||||
<appender-ref ref="RollingFileAppender" />
|
||||
</logger>
|
||||
</log4net>
|
|
@ -12,7 +12,8 @@ build_root := $(shell ./process_config.sh 'get' 'DEFAULT' 'IMAGE_BUILDER_ROOT')
|
|||
shared_files_dir := ${build_root}/share/files
|
||||
shared_scripts_dir := ${build_root}/share/scripts
|
||||
shared_images_dir := ${build_root}/share/images
|
||||
libvirt_images_dir := ${build_root}/libvirt/images
|
||||
#libvirt_images_dir := ${build_root}/libvirt/images
|
||||
libvirt_images_dir := $(shell ./process_config.sh 'get' 'DEFAULT' 'LIBVIRT_IMAGES_DIR')
|
||||
ps_modules_dir := ${CURDIR}/../WindowsPowerShell
|
||||
|
||||
commit_hash := $(shell git rev-list -n1 HEAD)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
IMAGE_BUILDER_ROOT = /opt/image-builder
|
||||
IMAGE_BUILDER_SHARE = $IMAGE_BUILDER_ROOT/share
|
||||
IMAGE_BUILDER_IP = 192.168.122.1
|
||||
LIBVIRT_IMAGES_DIR = $IMAGE_BUILDER_ROOT/libvirt/images
|
||||
|
||||
|
||||
[Windows Server 2012 Evaluation]
|
||||
|
@ -30,9 +31,9 @@ url = http://www.microsoft.com/en-us/download/details.aspx?id=11093
|
|||
|
||||
[VirtIO Drivers]
|
||||
mandatory = true
|
||||
name = virtio-win-0.1-74.iso
|
||||
name = virtio-win-0.1-81.iso
|
||||
path = $IMAGE_BUILDER_ROOT/libvirt/images
|
||||
url = http://alt.fedoraproject.org/pub/alt/virtio-win/stable/virtio-win-0.1-74.iso
|
||||
url = http://alt.fedoraproject.org/pub/alt/virtio-win/stable/virtio-win-0.1-81.iso
|
||||
|
||||
|
||||
[CloudBase-Init]
|
||||
|
@ -70,6 +71,12 @@ path = $IMAGE_BUILDER_ROOT/share/files
|
|||
url = https://www.dropbox.com/sh/zthldcxnp6r4flm/W-lgLFo7Fz/unzip.exe
|
||||
|
||||
|
||||
#[PowerShell V2]
|
||||
#mandatory = true
|
||||
#path = $IMAGE_BUILDER_ROOT/share/files
|
||||
#url = http://support.microsoft.com/kb/968929
|
||||
|
||||
|
||||
#[PowerShell V3]
|
||||
#mandatory = true
|
||||
#path = $IMAGE_BUILDER_ROOT/share/files
|
||||
|
|
|
@ -27,7 +27,7 @@ FLOPPY_IMG=${FLOPPY_IMG:-'floppy.img'}
|
|||
|
||||
|
||||
# Other variables
|
||||
LIBVIRT_IMAGES_DIR=$IMAGE_BUILDER_ROOT/libvirt/images
|
||||
LIBVIRT_IMAGES_DIR=${LIBVIRT_IMAGES_DIR:-$IMAGE_BUILDER_ROOT/libvirt/images}
|
||||
VM_IMG_NAME="$VM_NAME.$VM_IMG_FORMAT"
|
||||
VM_IMG_PATH="$LIBVIRT_IMAGES_DIR/$VM_IMG_NAME"
|
||||
VM_REF_IMG_PATH="$IMAGE_BUILDER_ROOT/share/images/$IMAGE_NAME.qcow2"
|
||||
|
|
|
@ -13,11 +13,11 @@ The following files **MUST** be added to the folder **$BUILD_ROOT/image-builder/
|
|||
* Far30b3367.x64.20130426.msi
|
||||
* SysinternalsSuite.zip
|
||||
* Git-1.8.1.2-preview20130201.exe
|
||||
* unzip.exe
|
||||
* unzip.exe
|
||||
|
||||
The following files will be build by other makefiles:
|
||||
* CoreFunctions.zip
|
||||
|
||||
The following files should be also added to the folder **$BUILD_ROOT/image-builder/share/files**, but in future they might also be built automatically:
|
||||
* MuranoAgent.zip
|
||||
* MuranoAgent.zip
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
</OOBE>
|
||||
<FirstLogonCommands>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
<CommandLine>powershell.exe -File C:\Murano\Scripts\ws-2008r2-std\Start-AtFirstBoot.ps1 -ExecutionPolicy Unrestricted</CommandLine>
|
||||
<RequiresUserInput>false</RequiresUserInput>
|
||||
<CommandLine>%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\Murano\Scripts\ws-2008r2-std\Start-AtFirstBoot.ps1 -ExecutionPolicy Unrestricted</CommandLine>
|
||||
<Order>1</Order>
|
||||
</SynchronousCommand>
|
||||
</FirstLogonCommands>
|
||||
|
@ -44,7 +44,7 @@
|
|||
</settings>
|
||||
<settings pass="generalize">
|
||||
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<SkipRearm>1</SkipRearm>
|
||||
<SkipRearm>0</SkipRearm>
|
||||
</component>
|
||||
</settings>
|
||||
<cpi:offlineImage cpi:source="wim:d:/aik/install.wim#Windows Server 2012 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
Function Get-InstalledSoftware{
|
||||
Param([String[]]$Computers)
|
||||
If (!$Computers) {$Computers = $ENV:ComputerName}
|
||||
$Base = New-Object PSObject;
|
||||
$Base | Add-Member Noteproperty ComputerName -Value $Null;
|
||||
$Base | Add-Member Noteproperty Name -Value $Null;
|
||||
$Base | Add-Member Noteproperty Publisher -Value $Null;
|
||||
$Base | Add-Member Noteproperty InstallDate -Value $Null;
|
||||
$Base | Add-Member Noteproperty EstimatedSize -Value $Null;
|
||||
$Base | Add-Member Noteproperty Version -Value $Null;
|
||||
$Base | Add-Member Noteproperty Wow6432Node -Value $Null;
|
||||
$Results = New-Object System.Collections.Generic.List[System.Object];
|
||||
|
||||
ForEach ($ComputerName in $Computers){
|
||||
$Registry = $Null;
|
||||
Try{$Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$ComputerName);}
|
||||
Catch{Write-Host -ForegroundColor Red "$($_.Exception.Message)";}
|
||||
|
||||
If ($Registry){
|
||||
$UninstallKeys = $Null;
|
||||
$SubKey = $Null;
|
||||
$UninstallKeys = $Registry.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall",$False);
|
||||
$UninstallKeys.GetSubKeyNames()|%{
|
||||
$SubKey = $UninstallKeys.OpenSubKey($_,$False);
|
||||
$DisplayName = $SubKey.GetValue("DisplayName");
|
||||
If ($DisplayName.Length -gt 0){
|
||||
$Entry = $Base | Select-Object *
|
||||
$Entry.ComputerName = $ComputerName;
|
||||
$Entry.Name = $DisplayName.Trim();
|
||||
$Entry.Publisher = $SubKey.GetValue("Publisher");
|
||||
[ref]$ParsedInstallDate = Get-Date
|
||||
If ([DateTime]::TryParseExact($SubKey.GetValue("InstallDate"),"yyyyMMdd",$Null,[System.Globalization.DateTimeStyles]::None,$ParsedInstallDate)){
|
||||
$Entry.InstallDate = $ParsedInstallDate.Value
|
||||
}
|
||||
$Entry.EstimatedSize = [Math]::Round($SubKey.GetValue("EstimatedSize")/1KB,1);
|
||||
$Entry.Version = $SubKey.GetValue("DisplayVersion");
|
||||
[Void]$Results.Add($Entry);
|
||||
}
|
||||
}
|
||||
|
||||
If ([IntPtr]::Size -eq 8){
|
||||
$UninstallKeysWow6432Node = $Null;
|
||||
$SubKeyWow6432Node = $Null;
|
||||
$UninstallKeysWow6432Node = $Registry.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall",$False);
|
||||
If ($UninstallKeysWow6432Node) {
|
||||
$UninstallKeysWow6432Node.GetSubKeyNames()|%{
|
||||
$SubKeyWow6432Node = $UninstallKeysWow6432Node.OpenSubKey($_,$False);
|
||||
$DisplayName = $SubKeyWow6432Node.GetValue("DisplayName");
|
||||
If ($DisplayName.Length -gt 0){
|
||||
$Entry = $Base | Select-Object *
|
||||
$Entry.ComputerName = $ComputerName;
|
||||
$Entry.Name = $DisplayName.Trim();
|
||||
$Entry.Publisher = $SubKeyWow6432Node.GetValue("Publisher");
|
||||
[ref]$ParsedInstallDate = Get-Date
|
||||
If ([DateTime]::TryParseExact($SubKeyWow6432Node.GetValue("InstallDate"),"yyyyMMdd",$Null,[System.Globalization.DateTimeStyles]::None,$ParsedInstallDate)){
|
||||
$Entry.InstallDate = $ParsedInstallDate.Value
|
||||
}
|
||||
$Entry.EstimatedSize = [Math]::Round($SubKeyWow6432Node.GetValue("EstimatedSize")/1KB,1);
|
||||
$Entry.Version = $SubKeyWow6432Node.GetValue("DisplayVersion");
|
||||
$Entry.Wow6432Node = $True;
|
||||
[Void]$Results.Add($Entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$Results
|
||||
Function Get-InstalledSoftware{
|
||||
Param([String[]]$Computers)
|
||||
If (!$Computers) {$Computers = $ENV:ComputerName}
|
||||
$Base = New-Object PSObject;
|
||||
$Base | Add-Member Noteproperty ComputerName -Value $Null;
|
||||
$Base | Add-Member Noteproperty Name -Value $Null;
|
||||
$Base | Add-Member Noteproperty Publisher -Value $Null;
|
||||
$Base | Add-Member Noteproperty InstallDate -Value $Null;
|
||||
$Base | Add-Member Noteproperty EstimatedSize -Value $Null;
|
||||
$Base | Add-Member Noteproperty Version -Value $Null;
|
||||
$Base | Add-Member Noteproperty Wow6432Node -Value $Null;
|
||||
$Results = New-Object System.Collections.Generic.List[System.Object];
|
||||
|
||||
ForEach ($ComputerName in $Computers){
|
||||
$Registry = $Null;
|
||||
Try{$Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$ComputerName);}
|
||||
Catch{Write-Host -ForegroundColor Red "$($_.Exception.Message)";}
|
||||
|
||||
If ($Registry){
|
||||
$UninstallKeys = $Null;
|
||||
$SubKey = $Null;
|
||||
$UninstallKeys = $Registry.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall",$False);
|
||||
$UninstallKeys.GetSubKeyNames()|%{
|
||||
$SubKey = $UninstallKeys.OpenSubKey($_,$False);
|
||||
$DisplayName = $SubKey.GetValue("DisplayName");
|
||||
If ($DisplayName.Length -gt 0){
|
||||
$Entry = $Base | Select-Object *
|
||||
$Entry.ComputerName = $ComputerName;
|
||||
$Entry.Name = $DisplayName.Trim();
|
||||
$Entry.Publisher = $SubKey.GetValue("Publisher");
|
||||
[ref]$ParsedInstallDate = Get-Date
|
||||
If ([DateTime]::TryParseExact($SubKey.GetValue("InstallDate"),"yyyyMMdd",$Null,[System.Globalization.DateTimeStyles]::None,$ParsedInstallDate)){
|
||||
$Entry.InstallDate = $ParsedInstallDate.Value
|
||||
}
|
||||
$Entry.EstimatedSize = [Math]::Round($SubKey.GetValue("EstimatedSize")/1KB,1);
|
||||
$Entry.Version = $SubKey.GetValue("DisplayVersion");
|
||||
[Void]$Results.Add($Entry);
|
||||
}
|
||||
}
|
||||
|
||||
If ([IntPtr]::Size -eq 8){
|
||||
$UninstallKeysWow6432Node = $Null;
|
||||
$SubKeyWow6432Node = $Null;
|
||||
$UninstallKeysWow6432Node = $Registry.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall",$False);
|
||||
If ($UninstallKeysWow6432Node) {
|
||||
$UninstallKeysWow6432Node.GetSubKeyNames()|%{
|
||||
$SubKeyWow6432Node = $UninstallKeysWow6432Node.OpenSubKey($_,$False);
|
||||
$DisplayName = $SubKeyWow6432Node.GetValue("DisplayName");
|
||||
If ($DisplayName.Length -gt 0){
|
||||
$Entry = $Base | Select-Object *
|
||||
$Entry.ComputerName = $ComputerName;
|
||||
$Entry.Name = $DisplayName.Trim();
|
||||
$Entry.Publisher = $SubKeyWow6432Node.GetValue("Publisher");
|
||||
[ref]$ParsedInstallDate = Get-Date
|
||||
If ([DateTime]::TryParseExact($SubKeyWow6432Node.GetValue("InstallDate"),"yyyyMMdd",$Null,[System.Globalization.DateTimeStyles]::None,$ParsedInstallDate)){
|
||||
$Entry.InstallDate = $ParsedInstallDate.Value
|
||||
}
|
||||
$Entry.EstimatedSize = [Math]::Round($SubKeyWow6432Node.GetValue("EstimatedSize")/1KB,1);
|
||||
$Entry.Version = $SubKeyWow6432Node.GetValue("DisplayVersion");
|
||||
$Entry.Wow6432Node = $True;
|
||||
[Void]$Results.Add($Entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$Results
|
||||
}
|
|
@ -24,7 +24,7 @@ Function Show-Variable {
|
|||
param (
|
||||
[String[]] $Name
|
||||
)
|
||||
|
||||
|
||||
Log logHorSeparator
|
||||
foreach ($VarName in $Name) {
|
||||
try {
|
||||
|
@ -70,9 +70,9 @@ function unzip()
|
|||
$destinationFolder = $shellApplication.NameSpace($dstPath);
|
||||
try
|
||||
{
|
||||
Log "Extracting $srcPath to $dstPath ...";
|
||||
Log "Extracting $srcPath to $dstPath ...";
|
||||
$destinationFolder.CopyHere($zipPackage.Items(),0x14);
|
||||
# 0x14 - force overwrite
|
||||
# 0x14 - force overwrite
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -90,8 +90,8 @@ function un-zip()
|
|||
try
|
||||
{
|
||||
Log "Unzipping $srcPath to $dstPath ...";
|
||||
#$unzipper=$srcScriptsPath+"\unzip.exe";
|
||||
$unzipper="$srcPacksPath\unzip.exe";
|
||||
#$unzipper=$srcScriptsPath+"\unzip.exe";
|
||||
$unzipper="$srcPacksPath\unzip.exe";
|
||||
Start-Process -FilePath $unzipper -ArgumentList "-e `"$srcPath`" -d `"$dstPath`"" -Wait
|
||||
}
|
||||
catch
|
||||
|
@ -111,7 +111,7 @@ function runexeinstaller()
|
|||
{
|
||||
Log "Running $installer ...";
|
||||
#Start-Process -FilePath $installer -ArgumentList /verysilent,/bash_context=1,/autocrlf=0,"/SetupType=custom /Components=icons,ext,ext\cheetah,assoc,assoc_sh" -Wait
|
||||
Start-Process -FilePath $installer -ArgumentList "$argList" -Wait
|
||||
Start-Process -FilePath $installer -ArgumentList "$argList" -Wait
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ function CreateDir()
|
|||
Log "Can not create $path, exiting...";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Log function
|
||||
|
@ -151,7 +151,7 @@ function Log()
|
|||
$datestamp = Get-Date -Format yyyyMMdd-HHmmss;
|
||||
$logString = "$datestamp`t$msg";
|
||||
if($LogLevel -ge 1)
|
||||
{
|
||||
{
|
||||
Write-Host "LOG:> $logString";
|
||||
}
|
||||
if($LogLevel -eq 2)
|
||||
|
@ -163,19 +163,19 @@ function Log()
|
|||
# Updating registry
|
||||
function AddToEnvPath()
|
||||
{
|
||||
param (
|
||||
$addString
|
||||
)
|
||||
param (
|
||||
$addString
|
||||
)
|
||||
$oldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
|
||||
if ($oldPath | Select-String -SimpleMatch "$addString")
|
||||
{
|
||||
{
|
||||
Log "$addString already within PATH=`"$oldPath`"";
|
||||
}
|
||||
else
|
||||
{
|
||||
$newPath=$oldPath+';'+$addString;
|
||||
$newPath=$oldPath+';'+$addString;
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
|
||||
Log "$addString was add to system PATH";
|
||||
Log "$addString was add to system PATH";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,13 +220,13 @@ foreach($file in $srcFiles)
|
|||
"MuranoAgent.zip"
|
||||
{
|
||||
un-zip $file.FullName $agentDir;
|
||||
Start-Sleep -s 5;
|
||||
& "$agentDir\WindowsAgent.exe" /install
|
||||
Start-Sleep -s 5;
|
||||
& "$agentDir\WindowsAgent.exe" /install
|
||||
}
|
||||
"CoreFunctions.zip"
|
||||
{
|
||||
un-zip $file.FullName $modulesDir;
|
||||
Start-Sleep -s 5
|
||||
Start-Sleep -s 5
|
||||
Import-Module "$modulesDir\CoreFunctions\CoreFunctions.psm1" -ArgumentList register;
|
||||
}
|
||||
"SysinternalsSuite.zip"
|
||||
|
@ -242,14 +242,14 @@ foreach($file in $srcFiles)
|
|||
"msysgit-1.8.3.exe"
|
||||
{
|
||||
$gitInstDir="$ENV:ProgramData\git";
|
||||
runexeinstaller $file.FullName "/verysilent /setuptype=custom /components=icons,ext,ext\cheetah,assoc,assoc_sh /bash_context=1 /autocrlf=0 /dir=$gitInstDir";
|
||||
Start-Sleep -s 5;
|
||||
AddToEnvPath "$gitInstDir\cmd";
|
||||
runexeinstaller $file.FullName "/verysilent /setuptype=custom /components=icons,ext,ext\cheetah,assoc,assoc_sh /bash_context=1 /autocrlf=0 /dir=$gitInstDir";
|
||||
Start-Sleep -s 5;
|
||||
AddToEnvPath "$gitInstDir\cmd";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Log $logHorSeparator;
|
||||
|
||||
|
@ -266,7 +266,7 @@ if($CanGo -eq 1)
|
|||
# Import-Module ServerManager
|
||||
# Install-WindowsFeature Server-Gui-Mgmt-Infra -Source 'wim:D:\sources\install.wim:2' -Restart:$false
|
||||
# For windows 2008 r2 x64
|
||||
New-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce -Name "PostInstallSysprep" -Value "$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe -Command `"& $srcScriptsPath\Start-Sysprep.ps1 -BatchExecution`""
|
||||
New-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce -Name "PostInstallSysprep" -Value "$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe -Command `"& $srcScriptsPath\Start-Sysprep.ps1 -BatchExecution`""
|
||||
|
||||
Log "Changing LowRiskFileTypes list"
|
||||
& reg ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Associations" /f /v "LowRiskFileTypes" /t REG_SZ /d ".exe;.bat;.reg;.vbs;.ps1;"
|
||||
|
@ -280,7 +280,7 @@ if($CanGo -eq 1)
|
|||
#Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0
|
||||
#New-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0 -PropertyType dword
|
||||
|
||||
Log "Starting Powershell 3 install ..."
|
||||
Start-Process -FilePath wusa.exe -ArgumentList "$srcPacksPath\Prereq\Windows6.1-KB2506143-x64.msu /quiet /forcerestart" -Wait;
|
||||
Log "Starting Powershell 3 install ..."
|
||||
Start-Process -FilePath wusa.exe -ArgumentList "$srcPacksPath\Prereq\Windows6.1-KB2506143-x64.msu /quiet /forcerestart" -Wait;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,4 +4,3 @@ foreach ($ServiceName in @('cloudbase-init')) {
|
|||
& "sc.exe" config "$ServiceName" start= auto
|
||||
Start-Service "$ServiceName"
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -4,4 +4,3 @@ foreach ($ServiceName in @('cloudbase-init')) {
|
|||
& "sc.exe" config "$ServiceName" start= auto
|
||||
Start-Service "$ServiceName"
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -4,4 +4,3 @@ foreach ($ServiceName in @('cloudbase-init')) {
|
|||
& "sc.exe" config "$ServiceName" start= auto
|
||||
Start-Service "$ServiceName"
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue