RSConfig 生成 Dsn 连接字符串不起作用
RSConfig generates a Dsn Connection String doesn't work
TL;DR。
重现步骤,备份你的 C:\Program Files\Microsoft SQL Server\MSRS13.SSRS\Reporting Services\ReportServer\RsReportServer.config
运行 此命令用于更新 SSRS 配置中的连接字符串:
C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn>rsconfig -c -s <ServerName> -i <instanceNameIfNotDefault> -d "reportserver$ssrs" -a SQL -u sa -p "YourSAPassword" -t
现在浏览到SSRS 网站,它不起作用!要修复它,请恢复您的配置文件或 运行 通过 SSRS GUI 工具,它会起作用!
RsConfig 实用程序如何工作?
背景
在 Windows 2016 服务器上安装 SSRS 并恢复 2 个数据库后,我需要更改 SSRS 配置文件中的连接字符串以指向新的 SQL 服务器 name/instance.
问题
当我尝试使用 RSConfig 实用程序更改 C:\Program Files\Microsoft SQL Server\MSRS13.SSRS\Reporting Services\ReportServer\RsReportServer.config
文件中的加密连接字符串时:
C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn>rsconfig -c -s Server0012 -i SSRS -d "reportserver$ssrs" -a SQL -u sa -p "P@ssw0rd!" -t
它更改了 RsReportServer.config 中的 Dsn 连接字符串。
之前:
AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAE+tJc/4Vs0a0fdH0tCY8kgQAAAAiAAAAUgBlAHAAbwByAHQAaQBuAGcAIABTAGUAcgB2AGUAcgAAABBmAAAAAQAAIAAAAC2DBxZFsfVB16r0e3……
*
之后:
AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAE+tJc/4Vs0a0fdH0tCY8kgQAAAAiAAAAUgBlAHAAbwByAHQAaQBuAGcAIABTAGUAcgB2AGUAcgAAABBmAAAAAQAAIAAAAO2nOjFDJMo.......
*
但是在进行此更改后,浏览到 SSRS 网站会导致错误:
The report server can’t connect to its database. Make sure the database is running and accessible. You can also check the report server trace log for details.
如果我 运行 SQL Reporting Services 配置工具 (GUI) 并更改浏览到 SSRS 网站的 Dsn 连接字符串就可以了!
显然它改变了 Dsn,但是当 GUI 工具处于 运行ning 状态时我不知道它还能做什么。我使用过 ProcessMonitor,我发现 GUI 工具 不 使用 RSConfig.exe 实用程序,它使用自己 RsConfigTool.exe!所以我什至无法捕获实际 command/connection 字符串应该是什么的命令行参数。此外,每次我们更改连接字符串时,都会生成一个新的随机字符串,因此不确定如何比较实际与预期。
我对注册表项进行了 WinDiff,除了一些加密的十六进制差异之外,没有什么特别的。
我 运行 SQLProfiler 并且我在我的 PowerShell 脚本中模拟了一堆授权,例如:
$sqls += @"
USE [ReportServer`$SSRSTempDB]
if not exists (select * from sysusers where issqlrole = 1 and name = 'RSExecRole')
BEGIN
EXEC sp_addrole 'RSExecRole'
END;
GO
我的直觉是 SQL 数据库名称中的 $ 符号和 "made up/simulated" 密码中的 @ 在我 运行 命令时没有被转义,例如:
$MachineName = "server0012"
$instanceName = "SSRS"
$saPassword = "P@ssw0rd!"
$rsConfigPath = "C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\rsconfig.exe"
$setupArgs = -join('-c -s "', $MachineName,'" -i "', $instanceName,'" -d ','"ReportServer`$SSRS" -t -a SQL -u "sa" -p "', $saPassword,"""")
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Write-Host $rsConfigPath $setupArgs
$args = $setupArgs.Split(" ")
& "$rsConfigPath" $args
Restart-Service -Force "SQL Server ($instanceName)"
当我 运行 命令提示符中的这些普通命令时(无需转义 PowerShell 字符):
rsconfig -c -s Server0012 -i SSRS -d "reportserver$ssrs" -a SQL -u sa -p "P@ssw0rd!"
它更改了 Dsn 连接字符串,但浏览到 SSRS 网站时出现相同的错误(如上)。
我如何才能知道 RsConfigTool.exe 在更改当前报表服务器数据库时还有什么作用?或者任何猜测为什么使用 RSConfig 实用程序生成的连接字符串不正常 - 我尝试了很多不同的组合,似乎只有 RSConfigTool 才能真正做到这一点?
注一:
我正在将这一切编写成一个 DevOps 项目,并且我们正在使用打包器烘焙这些图像,因此无法手动完成任何操作。
注2:
机器加入域并在 SQL 安装后重命名。因此,我认为使用 Configuration.ini 文件行不通。
问题不在于 RsConfigTool.exe。它有效,并且确实正确地更改了连接字符串。
问题简单地归结为单引号与双引号以及名称中的 $ 符号。
来自docs:
When you enclose a string in double quotation marks (a double-quoted
string), variable names that are preceded by a dollar sign ($) are
replaced with the variable's value before the string is passed to the
command for processing.
当我们尝试输出数据库名称时,我们可以看到这一点:
PS C:\> Write-Output "ReportServer$SSRS"
ReportServer
正如我们所见,它 returns "ReportServer" 然后是 $SSRS
变量(为空)的 contents。
为了证明这一点,如果我们为 $SSRS
变量创建并设置一个值:
PS C:\> $SSRS = "SomethingElse"
PS C:\> Write-Output "ReportServer$SSRS"
ReportServerSomethingElse
我们得到 "SomethingElse" ;-)。但是如果我们用单引号括起来,它不会做变量替换:
PS C:\> Write-Output 'ReportServer$SSRS'
ReportServer$SSRS
因此,解决方法是在从 PowerShell 调用 RsConfigTool.exe 工具时,只需将双引号替换为单引号即可:
rsconfig -c -s Server0012 -i SSRS -d 'reportserver$ssrs' -a SQL -u sa -p 'P@ssw0rd!' -t
诀窍是您需要使用 Powershell Invoke-Expression
命令,服务器名称必须包含不带引号的实例名称 server\instance,并且您需要转义 RsConfig.exe命令:-d ','"reportserver<tilda>$ssrs"'
= ` 转义 $ 符号的 tilda 键,参见下面的脚本。
如果您不使用 Invoke-Expression
并转义 $ 符号,则数据库名称称为 ReportServer 而不是 ReportServer$SSRS
您可以在 SSRS 日志中看到:
library!WindowsService_1!30c!05/17/2019-03:56:29:: e ERROR: Throwing
Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException:
,
Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException:
The report server cannot open a connection to the report server
database. A connection to the database is required for all requests
and processing. ---> System.Data.SqlClient.SqlException: A
network-related or instance-specific error occurred while establishing
a connection to SQL Server. The server was not found or was not
accessible. Verify that the instance name is correct and that SQL
Server is configured to allow remote connections. (provider: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
这是我用来修复已重命名的服务器上损坏的 SQL 安装的脚本:
Param(
[parameter(mandatory=$true,helpmessage="New Machine Name")]
[string]$MachineName,
[parameter(mandatory=$false,helpmessage="SQL Instance Name")]
[string]$instanceName = "SSRS",
[parameter(mandatory=$false,helpmessage="SQL SA Password")]
[string]$saPassword = "P@ssword1" #this is encrypted IRL
)
#1. Start the logging
Start-Transcript -Path "C:\temp\rename-ssrs-computer.txt"
#2. Change the SQL Server's name
Write-Host "Change the SQL Server Instance Name to $MachineName"
$moduleName = "SqlServer"
Import-Module $moduleName -Verbose
$sql = 'select @@SERVERNAME'
$serverNameQry = Invoke-SqlCmd -Serverinstance ".$instanceName" -Query $sql -username "sa" -password $saPassword -querytimeout ([int]::MaxValue)
$serverName = $serverNameQry.Column1
$sql = -join('sp_dropserver ''', $serverName,'''
GO
sp_addserver ''', $MachineName, "\", $instanceName,''',''local''
GO
')
Invoke-SqlCmd -Serverinstance ".$instanceName" -Query $sql -username "sa" -password $saPassword -querytimeout ([int]::MaxValue)
#3. Change the SSRS database permissions
$sqls = @()
$sqls += @"
USE master
DECLARE @AccountName nvarchar(260)
SET @AccountName = SUSER_SNAME(0x010100000000000514000000)
if not exists (select name from syslogins where name = @AccountName and hasaccess = 1 and isntname = 1)
BEGIN
EXEC sp_grantlogin @AccountName
END;
GO
"@
#..... all the SQL Profile trace outputs...#
Foreach ($sql in $sqls)
{
Invoke-SqlCmd -Serverinstance ".$instanceName" -Query $sql -username "sa" -password $saPassword -querytimeout ([int]::MaxValue)
}
#4. Change all the registry key values with the AMI Original Computer Name
Write-Host "Change the SQL Server Name in the Registry to $MachineName"
$txt = -join('Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server0\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server0\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server0\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Services\SSIS Server]
"GroupPrefix"="SQLServerDTSUser$',$MachineName,'"
"LName"=""
"Name"="MsDtsServer"
"Type"=dword:00000004
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Services\SSIS Server]
"GroupPrefix"="SQLServerDTSUser$',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Services\Report Server]
"Name"="ReportServer"
"LName"="ReportServer$"
"Type"=dword:00000006
"GroupPrefix"="SQLServerReportServerUser$',$MachineName,'$"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Services\Report Server]
"Name"="ReportServer"
"LName"="ReportServer$"
"Type"=dword:00000006
"GroupPrefix"="SQLServerReportServerUser$',$MachineName,'$"'
)
Add-Content "C:\temp\output.reg" $txt
regedit /s "C:\temp\output.reg"
#5. Set the encrypted connection string DONT CHANGE THIS!!!
$rsConfigPath = "C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\"
$setupArgs = -join('-c -s ', $MachineName, '\' , $instanceName,' -i ', $instanceName,' -d ','"reportserver`$ssrs"', ' -t -a SQL -u sa -p "', $saPassword,'"')
Write-Host "Setup args for RSConfig $rsConfigPath $setupArgs"
Write-Host "Running RSConfig"
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Write-Host $rsConfigPath $setupArgs
Set-Location "$rsConfigPath"
Invoke-Expression $("rsconfig.exe " + $setupArgs)
Write-Host "RSConfig Dsn complete, new Connection string under Dsn saved to rsconfig.config file."
#6. Restart the SQL Service
Write-Host "Restarting $instanceName"
Restart-Service -Force "SQL Server ($instanceName)"
Write-Host "Restarted $instanceName"
#7. Set regional format (date/time etc.) to English (Australia) - this applies to all users
Import-Module International
Set-Culture en-AU
# Check language list for non-US input languages, exit if found
$currentlist = Get-WinUserLanguageList
$currentlist | ForEach-Object {if(($.LanguageTag -ne "en-AU") -and ($.LanguageTag -ne "en-US")){exit}}
# Set the language list for the user, forcing English (Australia) to be the only language
Set-WinUserLanguageList en-AU -Force
Set-TimeZone -Name "AUS Eastern Standard Time"
# Lastly Stop the transcript (before the PC gets rebooted by the calling script).
Stop-Transcript
TL;DR。
重现步骤,备份你的 C:\Program Files\Microsoft SQL Server\MSRS13.SSRS\Reporting Services\ReportServer\RsReportServer.config
运行 此命令用于更新 SSRS 配置中的连接字符串:
C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn>rsconfig -c -s <ServerName> -i <instanceNameIfNotDefault> -d "reportserver$ssrs" -a SQL -u sa -p "YourSAPassword" -t
现在浏览到SSRS 网站,它不起作用!要修复它,请恢复您的配置文件或 运行 通过 SSRS GUI 工具,它会起作用!
RsConfig 实用程序如何工作?
背景
在 Windows 2016 服务器上安装 SSRS 并恢复 2 个数据库后,我需要更改 SSRS 配置文件中的连接字符串以指向新的 SQL 服务器 name/instance.
问题
当我尝试使用 RSConfig 实用程序更改 C:\Program Files\Microsoft SQL Server\MSRS13.SSRS\Reporting Services\ReportServer\RsReportServer.config
文件中的加密连接字符串时:
C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn>rsconfig -c -s Server0012 -i SSRS -d "reportserver$ssrs" -a SQL -u sa -p "P@ssw0rd!" -t
它更改了 RsReportServer.config 中的 Dsn 连接字符串。
之前:
之后:
但是在进行此更改后,浏览到 SSRS 网站会导致错误:
The report server can’t connect to its database. Make sure the database is running and accessible. You can also check the report server trace log for details.
如果我 运行 SQL Reporting Services 配置工具 (GUI) 并更改浏览到 SSRS 网站的 Dsn 连接字符串就可以了!
显然它改变了 Dsn,但是当 GUI 工具处于 运行ning 状态时我不知道它还能做什么。我使用过 ProcessMonitor,我发现 GUI 工具 不 使用 RSConfig.exe 实用程序,它使用自己 RsConfigTool.exe!所以我什至无法捕获实际 command/connection 字符串应该是什么的命令行参数。此外,每次我们更改连接字符串时,都会生成一个新的随机字符串,因此不确定如何比较实际与预期。
我对注册表项进行了 WinDiff,除了一些加密的十六进制差异之外,没有什么特别的。
我 运行 SQLProfiler 并且我在我的 PowerShell 脚本中模拟了一堆授权,例如:
$sqls += @"
USE [ReportServer`$SSRSTempDB]
if not exists (select * from sysusers where issqlrole = 1 and name = 'RSExecRole')
BEGIN
EXEC sp_addrole 'RSExecRole'
END;
GO
我的直觉是 SQL 数据库名称中的 $ 符号和 "made up/simulated" 密码中的 @ 在我 运行 命令时没有被转义,例如:
$MachineName = "server0012"
$instanceName = "SSRS"
$saPassword = "P@ssw0rd!"
$rsConfigPath = "C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\rsconfig.exe"
$setupArgs = -join('-c -s "', $MachineName,'" -i "', $instanceName,'" -d ','"ReportServer`$SSRS" -t -a SQL -u "sa" -p "', $saPassword,"""")
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Write-Host $rsConfigPath $setupArgs
$args = $setupArgs.Split(" ")
& "$rsConfigPath" $args
Restart-Service -Force "SQL Server ($instanceName)"
当我 运行 命令提示符中的这些普通命令时(无需转义 PowerShell 字符):
rsconfig -c -s Server0012 -i SSRS -d "reportserver$ssrs" -a SQL -u sa -p "P@ssw0rd!"
它更改了 Dsn 连接字符串,但浏览到 SSRS 网站时出现相同的错误(如上)。
我如何才能知道 RsConfigTool.exe 在更改当前报表服务器数据库时还有什么作用?或者任何猜测为什么使用 RSConfig 实用程序生成的连接字符串不正常 - 我尝试了很多不同的组合,似乎只有 RSConfigTool 才能真正做到这一点?
注一:
我正在将这一切编写成一个 DevOps 项目,并且我们正在使用打包器烘焙这些图像,因此无法手动完成任何操作。
注2:
机器加入域并在 SQL 安装后重命名。因此,我认为使用 Configuration.ini 文件行不通。
问题不在于 RsConfigTool.exe。它有效,并且确实正确地更改了连接字符串。
问题简单地归结为单引号与双引号以及名称中的 $ 符号。
来自docs:
When you enclose a string in double quotation marks (a double-quoted string), variable names that are preceded by a dollar sign ($) are replaced with the variable's value before the string is passed to the command for processing.
当我们尝试输出数据库名称时,我们可以看到这一点:
PS C:\> Write-Output "ReportServer$SSRS"
ReportServer
正如我们所见,它 returns "ReportServer" 然后是 $SSRS
变量(为空)的 contents。
为了证明这一点,如果我们为 $SSRS
变量创建并设置一个值:
PS C:\> $SSRS = "SomethingElse"
PS C:\> Write-Output "ReportServer$SSRS"
ReportServerSomethingElse
我们得到 "SomethingElse" ;-)。但是如果我们用单引号括起来,它不会做变量替换:
PS C:\> Write-Output 'ReportServer$SSRS'
ReportServer$SSRS
因此,解决方法是在从 PowerShell 调用 RsConfigTool.exe 工具时,只需将双引号替换为单引号即可:
rsconfig -c -s Server0012 -i SSRS -d 'reportserver$ssrs' -a SQL -u sa -p 'P@ssw0rd!' -t
诀窍是您需要使用 Powershell Invoke-Expression
命令,服务器名称必须包含不带引号的实例名称 server\instance,并且您需要转义 RsConfig.exe命令:-d ','"reportserver<tilda>$ssrs"'
如果您不使用 Invoke-Expression
并转义 $ 符号,则数据库名称称为 ReportServer 而不是 ReportServer$SSRS
您可以在 SSRS 日志中看到:
library!WindowsService_1!30c!05/17/2019-03:56:29:: e ERROR: Throwing Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: , Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing. ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
这是我用来修复已重命名的服务器上损坏的 SQL 安装的脚本:
Param(
[parameter(mandatory=$true,helpmessage="New Machine Name")]
[string]$MachineName,
[parameter(mandatory=$false,helpmessage="SQL Instance Name")]
[string]$instanceName = "SSRS",
[parameter(mandatory=$false,helpmessage="SQL SA Password")]
[string]$saPassword = "P@ssword1" #this is encrypted IRL
)
#1. Start the logging
Start-Transcript -Path "C:\temp\rename-ssrs-computer.txt"
#2. Change the SQL Server's name
Write-Host "Change the SQL Server Instance Name to $MachineName"
$moduleName = "SqlServer"
Import-Module $moduleName -Verbose
$sql = 'select @@SERVERNAME'
$serverNameQry = Invoke-SqlCmd -Serverinstance ".$instanceName" -Query $sql -username "sa" -password $saPassword -querytimeout ([int]::MaxValue)
$serverName = $serverNameQry.Column1
$sql = -join('sp_dropserver ''', $serverName,'''
GO
sp_addserver ''', $MachineName, "\", $instanceName,''',''local''
GO
')
Invoke-SqlCmd -Serverinstance ".$instanceName" -Query $sql -username "sa" -password $saPassword -querytimeout ([int]::MaxValue)
#3. Change the SSRS database permissions
$sqls = @()
$sqls += @"
USE master
DECLARE @AccountName nvarchar(260)
SET @AccountName = SUSER_SNAME(0x010100000000000514000000)
if not exists (select name from syslogins where name = @AccountName and hasaccess = 1 and isntname = 1)
BEGIN
EXEC sp_grantlogin @AccountName
END;
GO
"@
#..... all the SQL Profile trace outputs...#
Foreach ($sql in $sqls)
{
Invoke-SqlCmd -Serverinstance ".$instanceName" -Query $sql -username "sa" -password $saPassword -querytimeout ([int]::MaxValue)
}
#4. Change all the registry key values with the AMI Original Computer Name
Write-Host "Change the SQL Server Name in the Registry to $MachineName"
$txt = -join('Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server0\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server0\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server0\Machines]
"OriginalMachineName"="',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Services\SSIS Server]
"GroupPrefix"="SQLServerDTSUser$',$MachineName,'"
"LName"=""
"Name"="MsDtsServer"
"Type"=dword:00000004
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Services\SSIS Server]
"GroupPrefix"="SQLServerDTSUser$',$MachineName,'"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Services\Report Server]
"Name"="ReportServer"
"LName"="ReportServer$"
"Type"=dword:00000006
"GroupPrefix"="SQLServerReportServerUser$',$MachineName,'$"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Services\Report Server]
"Name"="ReportServer"
"LName"="ReportServer$"
"Type"=dword:00000006
"GroupPrefix"="SQLServerReportServerUser$',$MachineName,'$"'
)
Add-Content "C:\temp\output.reg" $txt
regedit /s "C:\temp\output.reg"
#5. Set the encrypted connection string DONT CHANGE THIS!!!
$rsConfigPath = "C:\Program Files (x86)\Microsoft SQL Server0\Tools\Binn\"
$setupArgs = -join('-c -s ', $MachineName, '\' , $instanceName,' -i ', $instanceName,' -d ','"reportserver`$ssrs"', ' -t -a SQL -u sa -p "', $saPassword,'"')
Write-Host "Setup args for RSConfig $rsConfigPath $setupArgs"
Write-Host "Running RSConfig"
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Write-Host $rsConfigPath $setupArgs
Set-Location "$rsConfigPath"
Invoke-Expression $("rsconfig.exe " + $setupArgs)
Write-Host "RSConfig Dsn complete, new Connection string under Dsn saved to rsconfig.config file."
#6. Restart the SQL Service
Write-Host "Restarting $instanceName"
Restart-Service -Force "SQL Server ($instanceName)"
Write-Host "Restarted $instanceName"
#7. Set regional format (date/time etc.) to English (Australia) - this applies to all users
Import-Module International
Set-Culture en-AU
# Check language list for non-US input languages, exit if found
$currentlist = Get-WinUserLanguageList
$currentlist | ForEach-Object {if(($.LanguageTag -ne "en-AU") -and ($.LanguageTag -ne "en-US")){exit}}
# Set the language list for the user, forcing English (Australia) to be the only language
Set-WinUserLanguageList en-AU -Force
Set-TimeZone -Name "AUS Eastern Standard Time"
# Lastly Stop the transcript (before the PC gets rebooted by the calling script).
Stop-Transcript