我试图运行以下代码来检索计算机上的本地用户列表.
gwmi win32_useraccount -Computername $env:computername -Filter "Domain='$env:computername'" |
Format-Table Name,Description
Run Code Online (Sandbox Code Playgroud)
在PS1文件中运行时出现此错误:
The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "f ormat-table" command which is conflicting with the default formatting. + CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperationException + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
我理解这个问题的出现是因为管道的解析方式,但我无法弄清楚如何绕过它.
这个条目似乎是我想要做的事情的80%,但我提出的任何工作都没有: bash:如何根据模式从数组中删除元素
我有两个数组:
@tapes_in_drives=(SP1026,SP0995,SP0434)
@tapes=(SP0001,SP0002,SP0434,SP0995,SP1026,SP2000,SP3000)
Run Code Online (Sandbox Code Playgroud)
我需要一个bash解决方案,可以删除@tapes中@tapes_in_drives中存在的所有条目.
我正在构建一个脚本,以根据到期日期等自动从磁带库中弹出磁带.
我试过这个:
for i in "${tapes_in_drives[@]}"; do
tapes=(${tapes[@]//*$i*})
done
Run Code Online (Sandbox Code Playgroud)
但它不起作用,没有任何东西被删除.
感谢您的任何帮助,您可以提供.
编辑:
这是我正在使用的代码,我最初是用Perl编写的,因此@variable定义,当我写这个问题时,我感到非常疲惫.
码:
#!/usr/bin/bash
# If media expires less than this many days, keep it
export days_expired="30"
# Set to 1 to get debug output to console
export debug="1"
# Get list of SPxxxxx tapes that are physically in the library
if [ $debug -eq 1 ]; then echo "Getting tape list"; fi
export tapes=`vmquery -rn 1 -b | tail +4 | awk …
Run Code Online (Sandbox Code Playgroud)