This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function something { | |
| [CmdletBinding()] | |
| param( | |
| ) | |
| write-verbose 'something verbose' | |
| } | |
| #outputs nothing | |
| something |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $dir = 'c:\temp' | |
| $who = 'domain\user' | |
| $acl = Get-Acl $dir | |
| $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($who,"Modify, DeleteSubdirectoriesAndFiles","ContainerInherit, ObjectInherit","None","Allow") | |
| $acl.AddAccessRule($rule) | |
| Set-Acl $dir $acl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $filefrom = 'c:\temp\something.txt' | |
| $fileto = 'c:\temp\1\something.txt' | |
| if (-not (test-path $fileto)) | |
| { | |
| $opts = @{'path' = $filefrom; 'destination' = $fileto; 'confirm' = $false} | |
| copy-item @opts | |
| } | |
| else | |
| { | |
| $opts = @{'path' = $filefrom; 'destination' = $fileto; 'confirm' = $true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #One-liner | |
| Invoke-WebRequest http://www.telize.com/geoip | ConvertFrom-Json | Format-Table Longitude,Latitude,Continent_Code,Timezone -AutoSize | |
| #Function | |
| function Get-GeoIP | |
| { | |
| param | |
| ( | |
| [array]$Attributes = '*', | |
| [IPAddress]$IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Computers = @('comp1','comp2'); Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computers | Format-Table PSComputerName,ServicePackMajorVersion,Version,@{N='BIOSSerial';E={$(Get-WMIObject -Class Win32_BIOS -ComputerName $_.PSComputerName).SerialNumber}} |
NewerOlder