codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
powershell 'test-path' do #stop script if directory exists code <<-EOH if (test-path "c:\\bin"){exit} EOH end powershell 'New-Item' do #Create a directory and assign permissions code <<-EOH New-Item "C:\\bin" –Type Directory Get-Acl "C:\\bin" | Format-List $acl = Get-Acl "C:\\bin" $rule = New-Object System.Security.AccessControl.FileSystemAccessRule('Administrators','FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow') $acl.AddAccessRule($rule) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule('chef','FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow') $acl.AddAccessRule($rule) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule('Users','Read', 'ContainerInherit, ObjectInherit', 'None', 'Allow') $acl.AddAccessRule($rule) Set-Acl "c:\\bin" $acl Get-Acl "c:\\bin" | Format-List EOH end powershell 'New-object' do #download a file into a directory code <<-EOH $client = new-object System.Net.WebClient $url = 'http://download.sysinternals.com/Files/SysinternalsSuite.zip' $bin = "c:\\bin\\SysinternalsSuite.zip" [System.Net.GlobalProxySelection]::Select = [System.Net.GlobalProxySelection]::GetEmptyWebProxy() $client.DownloadFile($url,$bin) EOH end powershell 'New-object' do #extract file code <<-EOH $zipfilename = "c:\\bin\\sysinternalssuite.zip" $destination = "c:\\bin" $zipPackage = (new-object -com shell.application).NameSpace($zipfilename) $destinationFolder = (new-object -com shell.application).NameSpace($destination) $destinationFolder.CopyHere($zipPackage.Items()) EOH end
Private
[
?
]
Run code
Submit