0 votes

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

by (480 points)
0
$path = 'c:\windows'
if(get-item $path) {Write-Output 'Exists'}
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

0 votes
by (216k points)
selected by
Best answer

Hello,

Yes, that can be done:

$path = "\\SERVER\Share"

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

Related questions

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
0 answers

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
1 answer

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 by maarten.vaes (70 points)
0 votes
0 answers

Hi We try to achieve a script where Adaxes replaces all umlauts in the username and mail adress and also checks for duplicate usernames. ... $email Context.SetModifiedPropertyValue("mailNickname", $username) $Context.SetModifiedPropertyValue("mail", $email)

asked Nov 11, 2020 by maca (100 points)
3,552 questions
3,242 answers
8,243 comments
547,828 users