Run Powershell as Daemon
hi guys!
today i'm going mad!
is possible run powershell script daemon?
i have confused ideas it's better if tell what's in mind:
i need create message (something keep attention) if open files particular extensions folder fileserver.
i think: maybe powershell can read directly fileserver kind of files open , open files!
but can't run script 1 time only, need to keep script running.
ok, maybe scheduling can resolve last thing please tell me if underlined things possible please!
a
hi a,
i find function can open files , user on file server:
function get-openfiles{ param( $computername=@($env:computername), $verbose=$false) $collection = @() foreach ($computer in $computername){ $netfile = [adsi]"winnt://$computer/lanmanserver" $netfile.invoke("resources") | foreach { try{ $collection += new-object psobject -property @{ id = $_.gettype().invokemember("name", ‘getproperty’, $null, $_, $null) itempath = $_.gettype().invokemember("path", ‘getproperty’, $null, $_, $null) username = $_.gettype().invokemember("user", ‘getproperty’, $null, $_, $null) lockcount = $_.gettype().invokemember("lockcount", ‘getproperty’, $null, $_, $null) server = $computer } } catch{ if ($verbose){write-warning $error[0]} } } } return $collection }
refer to:
viewing open files on file server powershell.
and if want send message remote server, can try cmd "msg /server:servernamehere * /v msggoeshere".
if there else regarding issue, please feel free post back.
best regards,
anna wang
Windows Server > Windows PowerShell
Comments
Post a Comment