Anlage des Repos
This commit is contained in:
61
examples/PowerShell/AccessTests/AccessRights.ps1
Normal file
61
examples/PowerShell/AccessTests/AccessRights.ps1
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
Set-Variable -name file -Value E:\test.pdf
|
||||
|
||||
function checkFileStatus1($filePath)
|
||||
{
|
||||
write-host (get-Date) "[ACTION][FILECHECK] Checking if" $filePath "is locked"
|
||||
$fileInfo = New-Object System.IO.FileInfo $filePath
|
||||
|
||||
try
|
||||
{
|
||||
$fileStream = $fileInfo.Open( [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read )
|
||||
write-host (get-Date) "[ACTION][FILEAVAILABLE]" $filePath
|
||||
#$fileInfo.close()
|
||||
#$fileInfo.dispose()
|
||||
|
||||
|
||||
|
||||
return $true
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
write-host (get-Date) "[ACTION][FILELOCKED] $filePath is locked"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function checkFileStatus2($filePath)
|
||||
{
|
||||
write-host (get-Date) "[ACTION][FILECHECK] Checking if" $filePath "is locked"
|
||||
$fileInfo = New-Object System.IO.FileInfo $filePath
|
||||
|
||||
try
|
||||
{
|
||||
$fileStream = $fileInfo.Open( [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read )
|
||||
#$fileStream = $fileInfo.Open()
|
||||
write-host (get-Date) "[ACTION][FILEAVAILABLE]" $filePath
|
||||
$fileInfo.close()
|
||||
$fileInfo.dispose()
|
||||
#$fileStream = $fileInfo.Open( [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read )
|
||||
|
||||
|
||||
return $true
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
write-host (get-Date) "[ACTION][FILELOCKED] $filePath is locked"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkFileStatus2 -filePath $file
|
||||
# checkFileStatus1 -filePath $file
|
||||
Reference in New Issue
Block a user