-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckWebConfigReadOnly.ps1
42 lines (38 loc) · 1.09 KB
/
checkWebConfigReadOnly.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function BagCheckWebConfigReadOnly{
param(
[string]$Path="D:\tfs\",
[string]$Folder1="WebUI",
[string]$Folder2="WebUI",
[bool]$Debug=$false,
[bool]$Fix=$false)
if(-NOT $Debug){ $ErrorActionPreference = "Stop" }
Try{
$error=$false;
$items=get-childitem "D:\tfs\" -Recurse -Filter "web.config" -Attributes ReadOnly
ForEach($item in $items)
{
if(-NOT ($item.DirectoryName.EndsWith($Folder1,"CurrentCultureIgnoreCase") -OR
$item.DirectoryName.EndsWith($Folder2,"CurrentCultureIgnoreCase")))
{continue}
if($Debug)
{
Write-Host "File" $item.Fullname
Write-Host "Dir" $item.DirectoryName
Write-Host "Mode" $item.Mode
}
write-host "ERROR: File " $item.Fullname " is readonly" -ForegroundColor Red
$error=$true;
}
if(-NOT $error)
{
write-host "OK: (All web.config files are not readonly)" -ForegroundColor Green
}
}
Catch
{
if(-NOT $Debug)
{
write-host "Exception: (Function: BagCheckWebConfigReadOnly, Message : " $_.Exception.Message ")" -ForegroundColor Red
}
}
}