I've been charged with converting a bash script running in cygwin to a powershell script. The goal of the script is to copy files that randomly drop into a directory, to another directory depending on the file name. I've got the basic idea of how I want my script to run. But I want to take this as a opportunity to learn/utilize pester.
I'm posting on the forum because I have no idea where to start on writing a test that ensures a file was copied from one directory, to the appropriate directory.
Use this for you Pester ramp up...
As for this..
.. you can do this by building and using a WMI Event monitor to watch a folder for writes.
There are plenty of examples and articles on this topic. Use you search engine of choice to bring up a list.
Use Get-ChildItem using a filter for the file names, the pipe that to the Copy-Item cmdlet to send to your destination.
# Get parameters, examples, full and Online help for a cmdlet or function (Get-Command -Name Get-ChildItem).Parameters Get-help -Name Get-ChildItem -Examples Get-help -Name Get-ChildItem -Full Get-help -Name Get-ChildItem -Online (Get-Command -Name Copy-Item).Parameters Get-help -Name Copy-Item -Examples Get-help -Name Copy-Item -Full Get-help -Name Copy-Item -Online
You must be logged in to reply to this topic.