Returning a value for if a directory exists - Using Path Wilcard %users%
I am trying to do either a custom inventory rule or script or both in the K1000 that I can use to see if a directory exists on a computer. If I run it in Powershell itself I get the results I am looking for, whether I am outputting it to a text file or just viewing the results in the window itself. I can get it to somewhat work in KACE, but never get the actual results. I can have it output the file, but it's blank. The problem is, I am trying to find out if it exists on certain desktop folders, so I can't just use a static location to verify if it exists or not. I get results in Powershell itself if I use the following 3 commands (with our without the output):
gci -Recurse -Filter "My Folder Here" -Directory -ErrorAction SilentlyContinue -Path "C:\Users" | Out-File -LiteralPath c:\testout.txt
gci -Recurse -Filter "My Folder Here" -Directory -ErrorAction SilentlyContinue -Path "C:\Users" > C:\testout.txt
Get-ChildItem C:\Users -recurse | Where-Object {$_.PSIsContainer -eq $true -and $_.Name -match "My Folder Here" -Directory}
I'm sure I'm thinking too hard about this, but either way I need some help getting pointed in the right direction please.
-
Try to wrap the command in ShellCommandTextReturn in a custom inventory rule. - flip1001 2 years ago
Answers (1)
I’m pretty sure that if you create a custom software inventory item and you click on the little question mark next to the custom inventory section, there is a similar example for this in there, something like
DirectoryExists(C:\WINDOWS\ )Comments:
-
W L M - DirectoryExists(path) is in that help section, however I don't believe it allows wildcards. I am wanting to see if a directory exists on users desktops. Not just for 1 user, but all users. I tried using the "%username%" wildcard to see if it would work and it did not. - timothy.n.white 2 years ago
-
The word 'wildcard' was just mentioned here for the first time, a key detail omitted from initial statement.
I'm editing this post's title. - Channeler 2 years ago