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
有没有办法将windows类型的进度条添加到运行Dism的powershell脚本中?_Powershell_Progress Bar_Dism - Fatal编程技术网

有没有办法将windows类型的进度条添加到运行Dism的powershell脚本中?

有没有办法将windows类型的进度条添加到运行Dism的powershell脚本中?,powershell,progress-bar,dism,Powershell,Progress Bar,Dism,我正在尝试将windows类型的进度条添加到运行Dism的powershell脚本中。我在使用win32_服务时遇到困难。有人知道怎么做吗 dism/Apply Image/ImageFile:Z:\path\wim.wim/Index:1/ApplyDir:C:\同意Mathias R.Jessen的观点 制作和使用PowerShell进度条在PowerShell内置帮助文件和整个web中都有很好的文档记录。下面是一篇关于 作者通过单曲的GIF提供和展示 For ($i=0; $i -le 1

我正在尝试将windows类型的进度条添加到运行Dism的powershell脚本中。我在使用win32_服务时遇到困难。有人知道怎么做吗


dism/Apply Image/ImageFile:Z:\path\wim.wim/Index:1/ApplyDir:C:\

同意Mathias R.Jessen的观点

制作和使用PowerShell进度条在PowerShell内置帮助文件和整个web中都有很好的文档记录。下面是一篇关于

作者通过单曲的GIF提供和展示

For ($i=0; $i -le 100; $i++) {
    Start-Sleep -Milliseconds 20
    Write-Progress -Activity "Counting to 100" -Status "Current Count: $i" -PercentComplete $i -CurrentOperation "Counting ..."
}
和嵌套的进度条

For ($i=0; $i -le 100; $i++) {
    Start-Sleep -Milliseconds 1
    Write-Progress -Id 1 -Activity "First Write Progress" -Status "Current Count: $i" -PercentComplete $i -CurrentOperation "Counting ..."

    For ($j=0; $j -le 100; $j++) {
        Start-Sleep -Milliseconds 1
        Write-Progress -Id 2 -Activity "Second Write Progress" -Status "Current Count: $j" -PercentComplete $j -CurrentOperation "Counting ..."
    }
}
另外,您使用WQL与内置PowerShell cmdlet查看服务的原因是什么

Get-Service | Where-Object {$_.Status -eq "Running"}
以及为什么您需要一个进度条,因为返回是即时的,而输出只是名称?你可以这么做

(Get-Service | Where-Object {$_.Status -eq "Running"}).Name

每一个都会有一个非常快的返回,即除非您使用Start-Sleep cmdlet故意减慢进度条的速度,否则进度条是没有意义的,但应该没有什么理由这样做

如果您正在寻找带有DISM进度条的脚本。请参见此处的讨论和预构建示例:


提供的公认答案是一段很长的代码,太长,无法在此处发布:

dism与win32_服务有什么关系??您好,感谢您的快速回复。我正在尝试使用下面的脚本$wmiQuery=“从win32选择名称”\u服务,其中状态='running'$colItems=Get WmiObject-Query$wmiQuery For($i=1;$i-le$colItems.count;$i++){写入进度-活动“收集服务”-状态“找到服务$i”`-percentComplete($i/$colItems.count*100)}$colItems |选择名称您最好更新您的问题,而不是将此代码放在注释部分。
Get-Service | Where-Object {$_.Status -eq "Running"} | Select-Object -Property Name