简体   繁体   English

如何从Powershell AD模块获取完整的SID并在SSIS中运行

[英]How to get full SID from powershell AD module and run in SSIS

I m developing a SSIS package to get all disabled account from AD. 我正在开发一个SSIS包,以从AD获取所有禁用的帐户。 I want to get the full SID and put into a file. 我想获取完整的SID并放入文件中。 But it not allow me to do that. 但这不允许我这样做。

Right now I m having this code which works fine in my package: 现在,我有了在我的程序包中可以正常工作的以下代码:

-executionpolicy remotesigned -command "import-module activedirectory; search-adaccount -accountdisabled |ft SamAccountName, SID" >d:\scripts\disabledaccount\DisabledAccount.txt

But this only returns SID like: S-1-5-21-1219070818-4200922009-29827... 但这只会返回SID,例如:S-1-5-21-1219070818-4200922009-29827 ...

So I need the full SID. 所以我需要完整的SID。 I tried to run this code in Powershell AD : 我试图在Powershell AD中运行以下代码:

import-module activedirectory; search-adaccount -accountdisabled |ft SamAccountName,@{Label="SID";Expression={$_.SID};width=50;align="left"} >d:\scripts\disabledaccount\DisabledAccount.txt

and it works fine. 而且效果很好。 but when I try to run it in SSIS package it doesn't work because of @{Label="SID";Expression={$_.SID};width=50;align="left"} this part. 但是当我尝试在SSIS包中运行它时,由于这部分@ {Label =“ SID”; Expression = {$$。SID}; width = 50; align =“ left”},它无法正常工作。

Can any one let me know what should I put there to get the full SID? 任何人都可以让我知道应该放什么以获取完整的SID吗?

Instead of 'ft' ( Format-Table ), use Select-Object instead. 代替“ ft”( Format-Table ),使用Select-Object The Format-* cmdlets are actually manipulating the text to make it fit best in the console window; Format- * cmdlet实际上是在操纵文本以使其最适合控制台窗口。 you don't want that. 你不想要那个。 Just try 你试一试

Search-ADAccount -AccountDisabled | Select-Object SamAccountName, SID

and see that that gets you. 并看到那让你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM