Discuss , our SFTP/FTP/FTPS/SCP server for Windows. Secure, fast and customizable!

Powershell Event

no avatar
User

ChrisMcLean

Posts

1

Joined

Fri Sep 12, 2014 5:10 am

Powershell Event

by ChrisMcLean » Fri Sep 12, 2014 5:14 am

I'm wanting to use powershell to extract the contents of a zip file to a different directory once a zip is upload, but only for a specific user. Ex:

Filter: /home/bob/*.zip

PS script:
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}

Expand-ZIPFile -file $args[0] -destination 'c:\temp'

I was assuming args[0] would be the file name of the just uploaded file, but that doesn't seem to be the case. How do I get the file name?
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Powershell Event

by support2 » Fri Sep 12, 2014 5:34 am

Have you tried using the substitution macros? e.g %WindowsPath% is the full Windows path of the file.

Who is online

Users browsing this forum: No registered users and 2 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron