Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PowerShell循环末尾的空项_Powershell_Registry - Fatal编程技术网

PowerShell循环末尾的空项

PowerShell循环末尾的空项,powershell,registry,Powershell,Registry,我正在使用问题末尾列出的脚本(的修改版本)搜索注册表。输出基本上是正确的,但我在末尾得到了一组额外的“Key:Reason:Details:”行。以下是输出,显示最后一个正确的块,后跟空块: VERBOSE: Key: 'HKEY_CURRENT_USER\SOFTWARE\blahblah\ProgId' Key : 'HKEY_CURRENT_USER\SOFTWARE\blahblah\ProgId' Reason : ValueData Details : {'foo.Clas

我正在使用问题末尾列出的脚本(的修改版本)搜索注册表。输出基本上是正确的,但我在末尾得到了一组额外的“Key:Reason:Details:”行。以下是输出,显示最后一个正确的块,后跟空块:

VERBOSE: Key: 'HKEY_CURRENT_USER\SOFTWARE\blahblah\ProgId' Key : 'HKEY_CURRENT_USER\SOFTWARE\blahblah\ProgId' Reason : ValueData Details : {'foo.Class1'} VERBOSE: Key: 'HKEY_CURRENT_USER\SOFTWARE\blahblah\Version' VERBOSE: Key: 'HKEY_CURRENT_USER\SOFTWARE\blahblah\VersionIndependentProgID' Key : Reason : Details : 下面是一个调用示例:

search-registry-detailed.ps1 -Path 'HKCU:\SOFTWARE\Classes\Wow6432Node\CLSID' -recurse -SearchRegex "foo" -ErrorAction SilentlyContinue -Verbose |
    Select Key,Reason,Details | fl

将最后一条语句
Write Output(“已用秒数:{0}”-f$sw.eassed.TotalSeconds)
更改为
Write Verbose(“已用秒数:{0}”-f$sw.eassed.TotalSeconds)
并在命令行上添加
-Verbose
开关以查看输出。@在示例中,他已经打开了
-Verbose
开关,谢谢!但是,如果我希望打印输出,而不管我是否使用
-Verbose
?我可以使用
写警告
,但我不希望输出前面有“警告”。如果我使用
写入信息
写入主机
,则输出不会出现在控制台或我重定向输出到的文件中(通过
tee
)。如果我使用
[string]::Format(“Seconds appeased={0}”,$sw.appeased.TotalSeconds)
,我会得到与我最初提到的相同的空白“Key:…”输出。
search-registry-detailed.ps1 -Path 'HKCU:\SOFTWARE\Classes\Wow6432Node\CLSID' -recurse -SearchRegex "foo" -ErrorAction SilentlyContinue -Verbose |
    Select Key,Reason,Details | fl