Agenda
Designed by Jeffrey Snover, Bruce Payette, James Truher (et al.)
Developer Microsoft
First appeared November 14, 2006
Stable release 5.1.14393 / August 2, 2016; 8 months ago
Preview release 6.0.0 Alpha 17 / March 8, 2017; 35 days ago
Typing discipline Strong, safe, implicit and dynamic
Platform .NET Framework, .NET Core
OS Windows 7 and later, macOS, CentOS, Ubuntu
Filename extensions
•.ps1 (Script)
•.ps1xml (XML Document)
•.psc1 (Console File)
•.psd1 (Data File)
•.psm1 (Script Module)
•.pssc (Session Configuration File)
•.cdxml (Cmdlet Definition XML Document)
What’s Need ?
Machine management
ConvertTo-SecureString :- Convert any string into Encrypted form
-AsSecureString :- Take input from user in secure way
$var = Read-Host -AsSecureString
$var1 = ConvertTo-SecureString -SecureString $var
Filtering
Write-Host is having more attributes
Write-Host –NoNewLine “Counting from 1 to 9 (in seconds): “
foreach($element in 1..9){
Write-Host –NoNewLine “${element} “
Start-Sleep –Seconds 1
}
Write-Host “”
Output :- Counting from 1 to 9 (in seconds): 1 2 3 4 5 6 7 8 9
Write-Output
Write-Output should be used when you want to send data on in the pipe line, but not necessarily want to display it on screen.
PS C:\> Write-Output"test output" | Get-Member
This command pipes the "test output" string to the Get-Member cmdlet, which displays the members of the System.String class, demonstrating that the string was passed along the pipeline.
Loops
ForEach is specially used to fetch elements from an array
While/ Do-While Loop
While :- As long as the condition remains true, PowerShell reruns the {command_block} section.
while($val -ne 10) { $val++ Write-Host $val }
Do-While:- First the Command Block will run and then it will check condition
Do {
$val++ Write-Host $val
} while($val -ne 10)
Importing
}
Posted 12 April 2021
© 2021 TechTarget, Inc.
Powered by
Badges | Report an Issue | Privacy Policy | Terms of Service
Most Popular Content on DSC
To not miss this type of content in the future, subscribe to our newsletter.
Other popular resources
Archives: 2008-2014 | 2015-2016 | 2017-2019 | Book 1 | Book 2 | More
Most popular articles
You need to be a member of Data Science Central to add comments!
Join Data Science Central