I was wondering how to use the powershell context check to see if a folder exists before a copy action starts.

by (480 points)
by (460 points)
0
$path = 'c:\windows'
if(get-item $path) {Write-Output 'Exists'}
by (480 points)
0

Sorry, I guess that my initial question was not clear. I am hoping to build an action in a custom command that if a folder is found then the copy action would complete. Basically something to go with:
# The condition is met if $Context.ConditionIsMet is set to $True.
$Context.ConditionIsMet = $False

1 Answer

by (216k points)
Best answer
0 votes

Hello,

Yes, that can be done:

$path = "\\SERVER\Share"

$item = Get-Item $path -ErrorAction SilentlyContinue -Force
$Context.ConditionIsMet = !($item -eq $NULL)

Related questions

Hi, I was able to activate the shared folder object type as I browse through a webinterface. Now I face the issue that I am not able to search it via the websearch. Is it possible to add it somehow to the searchable objects? Thanks in advance!

asked Sep 2 by Marcel Büttinghaus (60 points)
0 votes
1 answer

Hi, I need a script that will retrospectively create a sub-folder on file server's shared folder with following permissions: employee his/hers manager (taken from AD) specific ... for more pre-existing users that don't have them. Thanks for any feedback.

asked Nov 3, 2020 by roberttryba (70 points)
0 votes
1 answer

How would a script be written that accomplishes the following task? In this scenario, UserA would be selected with the Modify user action, then UserB would be input to ... rule that runs the script to allow reviewer permissions on UserA's calendar for UserB

asked Dec 6, 2012 by mdeflice (350 points)
0 votes
1 answer

We are trying to create a custom command to create a new network share folder and offline PST file for new users. Do you have any documentation to start our process with>

asked Jan 10, 2017 by willy-wally (3.2k points)
0 votes
0 answers

Hello, When a user is disabled (firstname.lastname@company.com) we would like to to perform a check if a user account "admin-firstname.lastname@company.com" exists in ... email with this information. Could this be done with powershell? Best Regards, Maarten

asked Mar 18, 2024 by maarten.vaes (140 points)
0 votes
1 answer