-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttribute Changer.ps1
More file actions
38 lines (28 loc) · 1.09 KB
/
Attribute Changer.ps1
File metadata and controls
38 lines (28 loc) · 1.09 KB
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
############################## GLOBALS ##############################
$global:debug = 0
$global:display = 'Normal'
$global:title = 'Attribute Changer'
$global:args = $args
############################## MAIN CODE ##############################
function main {
if ($global:debug) { $global:args; '' }
foreach ($arg in $global:args) {
if (Test-Path $arg) {
$file = Get-Item $arg -Force
if ($global:debug) { $file.Attributes }
if ($global:args[0] -eq 'r') {
if ($file.Attributes -match 'ReadOnly') { $file.Attributes = $file.Attributes -Replace '(, )?ReadOnly(, )?', '' }
else { $file.Attributes = $file.Attributes -Replace '(.+)', '$1, ReadOnly' }
}
elseif ($global:args[0] -eq 's') {
if ($file.Attributes -match 'System') { $file.Attributes = $file.Attributes -Replace '(, )?Hidden(, )?System(, )?', '' }
else { $file.Attributes = $file.Attributes -Replace '(.+)', '$1, Hidden, System' }
}
if ($global:debug) { $file.Attributes }
}
}
if ($global:debug) { ''; pause }
exit
}
############################## RUN MAIN CODE ##############################
main