我正在创建一个PowerShell脚本来检查OU用户是否已针对已配置文件共享存档的用户进行检查,但我遇到了绊脚石。 我可以查询AD以获取每个OU及其主目录的用户列表,将所有详细信息转储到日志的文本文件中并基于后续查询。 获得这些详细信息后,我尝试运行dos命令(Enterprise Vault)Archivepoints.exe将变量传递给它。 该命令通常是:
Archivepoints.exe find \\fopserver045v\ouone_users$当我尝试运行以下代码时出现错误。
$app="D:\Enterprise Vault\ArchivePoints.exe" $EVArg = "find" $VolLine = "\\fopserver045v\ouone_users_r$" Invoke-Item "$app $EVArg $VolLine" Invoke-Item : Cannot find path 'D:\Enterprise Vault\ArchivePoints.exe find \fopserver045v\ouone_users_r$' because it does not exist.起初我以为它错过了导致问题的UNC路径的第一个反斜杠,但我不再确定。
脚本和命令在EV服务器上运行,UNC浴缸实际上并没有进入服务器,它只是EV中的参考路径,因此它不是凭证问题。
如果可能的话,我还需要能够将输出记录到文件中。
代码应该是什么样的,我应该使用invoke-command还是Invoke-Expression?
谢谢
I’m in the process of creating a powershell script to check OU users against users already configured for file share archiving but I’ve hit a stumbling block. I can query AD to get a list of users per OU and their home directories, dumping all of the details out to text files for logs and basing subsequent queries on. Once I have these details I try to run a dos command, (Enterprise Vault) Archivepoints.exe passing variables to it. The command would usually be :
Archivepoints.exe find \\fopserver045v\ouone_users$When I try to run the following code I get an error.
$app="D:\Enterprise Vault\ArchivePoints.exe" $EVArg = "find" $VolLine = "\\fopserver045v\ouone_users_r$" Invoke-Item "$app $EVArg $VolLine" Invoke-Item : Cannot find path 'D:\Enterprise Vault\ArchivePoints.exe find \fopserver045v\ouone_users_r$' because it does not exist.At first I thought it was missing the first backslash of the UNC path that was causing the issue but I'm no longer sure.
The script and command run on the EV server and the UNC bath doesn't actually go to the server, it's only a reference path within EV so it's not a credentials issue.
I need to be able to log the output to file too if possible.
What should the code look like and should I be using invoke-command or Invoke-Expression instead ?
Thanks
最满意答案
不要使用Invoke-Item 。 应使用调用运算符( & )运行外部命令。 您可以使用splatting作为参数列表。
$app="D:\Enterprise Vault\ArchivePoints.exe" $arguments = "find", "\\fopserver045v\ouone_users_r$" & $app @argumentsDon't use Invoke-Item. External commands should be run using the call operator (&). You can use splatting for the argument list.
$app="D:\Enterprise Vault\ArchivePoints.exe" $arguments = "find", "\\fopserver045v\ouone_users_r$" & $app @arguments更多推荐
发布评论