I want to create a script which basically checks that a file exists in two locations.
If the file exists I want it to write "Yes" to a custom field I made.
If the file does not exist I want to write "No" to the custom field
The files I want to check for are:
I really suck a making this script and I bet this is so easy -.-
Wait, are these files or directories? 'test file' looks for a file with the name you've specified in the path you've declared.
If it's a file with no extension, you might need to use agent credential to do it as the agent may not be able to traverse those folders with the system account (perhaps)...
If it's a directory I'm not sure (i.e. I could be wrong) if you can test for directory using 'test file' - you might need to do it using a different command , parsing the result to a text file (or to variable) and reading that.
At the moment i've got this, and when I run it on servers I know are using WSB it reports back with "No".
The file and file path is completely specified.
Have you tried using an admin credential? It is possible that the system doesn't have rights to see that file.
I did try the usecredential switch but the outcome was the same.
I tried then dropping a batch file to the machine which was suppose to CD to the folder specified above and then output DIR to a txt file. I found that the batch file wouldn't open inside the last folder but running it on the server manually did.
I do think it's a permission issue with it going in to that "Backup" folder.
You can use a nested test file in this case. just put a test file on top of one. for example:
Check this on your server :)
thanks for the reply.
My issue was that whatever I did wouldn't work due to permissions.
Eventually I've made the following which does work:
My PS script line is:
Test-Path C:\Windows\System32\Tasks\Microsoft\Windows\Backup\Microsoft-Windows-WindowsBackup | Out-File C:\Temp\WSBResults.txt