使用GUI添加angular色和function时,还有一些额外的步骤可以让您进行一些额外的configuration。 例如,安装WSUS时,有几个标有“angular色服务”和“内容”的步骤,可让您select要使用的数据库并为此数据库设置位置。 (下图)
但是让我们说我想通过PowerShell来安装它。 我会input以下内容:
Import-Module servermanager Install-WindowsFeature -Name UpdateServices -IncludeAllSubFeature -IncludeManagementTools
然而,这并不能让我指定我想放置数据库的位置,就像GUI一样。 有没有什么命令可以让我从powershell进一步configurationWSUS?
谢谢。
有这样的相当多的function。 当我升级我们的WSUS服务器时,我使用这个命令来识别一个自定义数据库位置:
& "$env:programfiles\update services\tools\wsusutil.exe" postinstall CONTENT_DIR=E:\WSUS\
完成迁移到我们的新服务器需要许多其他步骤 – 我在服务器上分配一个新的guid后再次调用这个util。
另一个例子…安装pipe理工具包后,然后使用dism.exe 启用特定的工具,如Active Directory用户和计算机。
编辑:好的…这是我的脚本来得到我们的新的WSUS服务器。 请成员它是特定于我们的环境,并可能需要一些按摩来工作你的:
<# Initial setup script for WSUS 6.3 (Server 2012) Created : 12/02/2014 #> $oldserver = "[enter DNS name of old server]" $newserver = $env:ComputerName $WID = "\\.\pipe\Microsoft##WID\tsql\query" $WIDService = "MSSQL`$MICROSOFT##WID" Function Create-Group ([String]$name, [String]$desc) { $objOu = [ADSI]"WinNT://$newserver" $objGroup = $objOU.Create("group", $name) $objGroup.SetInfo() $objGroup.Description = $desc $objGroup.SetInfo() } Function Confirm($message) { $caption = "Confirm" $yes = new-Object System.Management.Automation.Host.ChoiceDescription "&Yes","help" $no = new-Object System.Management.Automation.Host.ChoiceDescription "&No","help" $choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no) $host.ui.PromptForChoice($caption,$message,$choices,0) } If (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "Script needs to be run as Administartor" Exit 0 } Else { If (Confirm("You are about to run the WSUS setup script. Do you want to continue?") -eq 1) { Exit 0 } } Import-Module SQLPS # Add the WSUS role to the server Write-Host "Installing the WSUS Server Role - post-install configuration will be run as part of this script" Install-WindowsFeature -Name UpdateServices -IncludeManagementTools -WhatIf Install-WindowsFeature -Name UpdateServices -IncludeManagementTools # Copy WSUS patches to new server Write-Host "Copying patch repository from \\$oldserver\E$\WSUS" Copy-Item "\\$oldserver\E$\WSUS" "\\$newserver\E$\" -Recurse # Copy WSUS database to new server Write-Host "Copying WSUS Database from \\$oldserver\E$\WSUS DB Backups\Backup.bak" Copy-Item "\\$oldserver\E$\WSUS DB Backups\Backup.bak" "\\$newserver\E$\TEMP" # Create WSUS Security groups on new server Write-Host "Creating WSUS access groups" Create-Group "WSUS Administrators" "WSUS Administrators can administer the Windows Server Update Services server." Create-Group "WSUS Reporters" "WSUS Administrators who can only run reports on the Windows Server Update Services server." # Populate groups via group policy gpupdate /force # Ensure the Windows Internal Database (WID) is running and set to auto startup Write-Host "Checking Windows Internal Database" (Get-Service -Name $WIDService -ComputerName $newserver).Start Set-Service -Name $WIDService -ComputerName $newserver -StartupType Automatic Start-Sleep -s 5 # Create a blank DB for new WSUS instance Write-Host "Creating blank DB for WSUS" $sql = New-Object Microsoft.SqlServer.Management.Smo.Server($WID) $db = New-Object Microsoft.SqlServer.Management.Smo.Database($sql, "SUSDB") $db.Create() Write-Host "DB created on " $db.CreateDate Start-Sleep -s 5 Write-Host "Restoring \\$newserver\E$\WSUS DB Backups\Backup.bak to new server" Write-Host "Note: there WILL be one warning" # Drop the newly created DB Invoke-SqlCmd -InputFile ".\SUSDB_Drop.sql" -ServerInstance $WID -OutputSqlErrors $True -Verbose Start-Sleep -s 5 # Restore the previous DB over the blank DB Invoke-SqlCmd -InputFile ".\SUSDB_Restore.sql" -ServerInstance $WID -OutputSqlErrors $True -Verbose Start-Sleep -s 5 # Run the WSUS postinstall command with the patch folder Write-Host "Identifying WSUS repository as E:\WSUS" & "$env:programfiles\update services\tools\wsusutil.exe" postinstall CONTENT_DIR=E:\WSUS\ # Give the WSUS instance a new identity (powershell) Write-Host "Creating new ID for WSUS server" $updateServer = Get-WsusServer -Name $newserver -Port 8530 $config = $updateServer.GetConfiguration() $config.ServerId = [System.Guid]::NewGuid() $config.Save() # Re-run the postinstall with the new identity Write-Host "Running WSUS postinstall with for ID" & "$env:ProgramFiles\Update Services\Tools\wsusutil.exe" postinstall # Change the WSUS service to run on port 80 (as per current server) Write-Host "Changing default WSUS port to port 80" & "$env:programfiles\update services\tools\wsusutil.exe" usecustomwebsite false # Replicate SQL security using query provided by DST Write-Host "Restoring SQL permissions" Invoke-SqlCmd -InputFile ".\SUSDB_RoleUsers.sql" -ServerInstance $WID -OutputSqlErrors $True -Verbose
一旦通过PowerShell安装了一个function,可以使用该function的PowerShell模块完成configuration。
然而,并不是所有的窗口function都具有完整的模块,您的WSUS移动WSUS数据库位置的任务就是这样一个例子。 但是,这并不意味着PowerShell不能用来完成这个任务,只是需要额外的步骤。
微软在这里有一篇technet文章,演示如何使用wsusutil命令行程序来设置数据库的位置。