Question

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

Was it helpful?

Solution

Don'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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top