我的代码通过运行sp_change_users_login 'report'
它返回两件事-a)用户名和b)usersid
UserSId用逗号分隔二进制文件,因此我正在使用Format-Hex
来获取用户的原始SID。
但是通过这种转换,它也返回了其他东西。我希望能解决。下面是带有输出的图片。
PS输出:
SQL输出
如何处理它并仅获得与mssql中相同的输出?
我的一段代码:
if($DBs -is [System.Array])
{
foreach($DB in $DBs)
{
$DB
$connection.ChangeDatabase($DB)
$connection.ChangeDatabase('DBName') ## Currently hardcoded.In actual, it will iterate.
$orphan_users_query = @"
sp_change_users_login 'report'
"@
$command = $connection.CreateCommand()
$command.CommandText = $orphan_users_query
$result = $command.ExecuteReader()
$object_orphan= New-Object System.Data.DataTable
$object_orphan.Load($result)
$object_orphan.UserSID | Format-Hex -Raw #| Out-File C:\temp\outfile_property1.txt -Append -Force
}
}
答案 0 :(得分:0)
这就是我如何处理混淆输出的情况,这种输出具有不错的格式。
TcpListener
输出现在是这样
Server.Start()
与sql输出完全匹配。因此,自动二进制转换实际上导致了该问题。