我有以下PS脚本:
const functions = require('firebase-functions');
const {
async_get_all_undeleted_posts,
async_get_post,
async_delete_post,
async_create_post
} = require('./handlers/posts');
exports.create_post = functions.https.onCall(async_create_post);
此脚本从PS命令行按预期运行:在指定的共享网络位置创建新文件时,它将将此文件解压缩到目标文件夹。 但是,如果我将脚本作为预定任务运行,则不会发生任何事情。
我正在使用以下选项进行计划:
$folder = "\\vwhd01\shared\zip_files" # Monitor FTP folder with incoming .
$filter = "*.zip" # Filter for zip files.
$destination = "T:\Deleteme" #Output for uncompressed files
$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.FullPath
$changeType = $Event.SourceEventArgs.ChangeType
$timeStamp = $Event.TimeGenerated
Expand-Archive -LiteralPath $name -DestinationPath "T:\Deleteme"
Write-Host "The file '$name' was $changeType at $timeStamp" -fore green }
# To stop the monitoring, run the following commands:
# Unregister-Event FileCreated
有人知道哪里出了问题吗?