Asked by:
Need help with powershell to prompt SaveAs diag box.

Question
-
Greetings!
I am a amatuer in powershell. After some digging in various forums, I found a simple powershell code which monitors a particular directory for any file changes(Creation) and if found, calls a batch file which copies the files to a designated path.
$folder = "C:\Users\$env:USERNAME\Documents\" # Enter the root path you want to monitor. $filter = '*.*' # You can enter a wildcard filter here. $fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'} Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { $name = $Event.SourceEventArgs.Name $changeType = $Event.SourceEventArgs.ChangeType $timeStamp = $Event.TimeGenerated Write-Host "The file '$name' was $changeType at $timeStamp" -fore green cmd.exe /c 'C:\FileCopy\Test1.bat' }
As you can see, this code monitors the documents folder of any user and if a new file is created/copied to this path, calls a Test1.bat file which contains a simple xcopy command to copy those files to a predefined directory path.
Now, what i want is a powershell script which monitors the said directory and if any changes found, gives the user a "SaveAs" dialogue box so user can choose his directory instead of just copying it to a fixed path.
Basically a file transfer box using which he can copy file/s to his/her selected directory.
Any guidance/help please.
Thanks
Wednesday, July 25, 2018 10:14 AM
All replies
-
I know you are having fun asking others to give you solutions. Unfortunately this is not a script trading forum. Pleaseuse your search engine t find examples f code that will help you do what you ask.
Please carefully review the following links to set your expectation for posting in technical forums.
This Forum is for Scripting Questions Rather than script requests
\_(ツ)_/
Wednesday, July 25, 2018 10:59 AM -
My question might have come out in a wrong way. Neither asking someone to write a script for me nor to correct the one i already have. I am a beginner with power shell and yet do not know a lot. I'm Learning.
I just wanted to know whether what i am trying to achieve is possible even. A SaveAs type diag box for moving files to a user provided path.
Just some guidance would help. Not a full script.
Will go through the links above.- Edited by MohitMahajan22 Thursday, July 26, 2018 7:02 AM
Thursday, July 26, 2018 6:58 AM -
You can use this:
https://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(v=vs.110).aspx
\_(ツ)_/
Thursday, July 26, 2018 7:04 AM