Ans: Power shell is an extendable command shell and a scripting language for Windows.
Ans: The key characteristics of PowerShell are
Ans: In variables PowerShell contains strings, integers and objects. It does not have special variables as it is pre-defined with PowerShell
Ans:
Ans: Cmdlet’s are simple build in commands written in .net language like C# or VB introduced by Windows PowerShell
Ans: Automating repetitive task with the help of PowerShell loop is known as PowerShell Loop. Through PowerShell, you can execute For each loop, While loop and Do While loop.
Ans: If you have created a web part using VS 2010 then, you can deploy it using cntrl+f5. However to activate the web part feature you can write a PowerShell script (.ps1) and execute it after deployment
Ans: Comparison Operators compares value in PowerShell. Four types of comparison operators are used equality, match, containment and replace. In PowerShell, one of the key comparison operators is –eq that is used instead of “=” sign for declaring variables. Likewise, there are other operators like –ne for “not equal” , -gt ( greater than ) or –lt (less than).
Ans: PowerShell pipeline is used for joining two statements such that the output of one statement becomes the input of the second.
Ans: Get command in PowerShell is used to fetch other cmdlets, for example you are looking for cmdlet between letter L and R then your PowerShell get-command will be like
# PowerShell Get – Command Range
Clear-Host
Get-Command [ L–R ]*
Ans: To map a network drive in PowerShell you have to use the command like
# PowerShell Map Network Drive
$Net = $( New – Object – ComObject Wscript.Network )
$Net.MapNetworkDrive( “S:”, \\expert\myTectra )
In here the drive letter is “S:” and the Network share is called ‘expert’ on a computer called ‘myTectra.’
Ans:
Ans: The cmdlets of windows enable you to filter the window services. PowerShell can list which services are ‘Running’ and which are ‘Stopped’ by scripting with windows.
Ans: PowerShell file contains a series of PowerShell commands with each command appearing on a separate line. To use a text file as a PowerShell script, its filename should have.PS1 extension. To run a script you need
Ans: A hash table is also referred as dictionary. It is an array that allows you to store data in a “key-value” pair association. The “key” and “value” can be of any data and length. To declare a hash table you have to use @ followed by curly braces.
Ans: The use of Array in PowerShell is to run a script against remote computers. In order to create an array, you have to create a variable and assign the array. Arrays are represented by “@”symbol, they are represented as hashtable but not followed by curly braces.
For example, $arrmachine = @ ( “machine1” , “machine2” , “machine3”)
Ans: To get all child folders in a specific folder, you have to use parameter recurse in the code.
Get-ChildItem C:\Scripts –recurse
Ans: To convert the object into HTML
Get-Process l Sort-object – property CPU –descending l convert to – HTML l Out-file “process.html”
Ans: To rename a variable,
Rename-Item- Path Env: MyVariable –NewName MyRenamedVar
Ans: The $input variable enables a function to access data coming from the pipeline
Ans: Get-WmiObject-Class Win32_Product- ComputerName . l Format-wide-column1
Ans:
There are two ways to do this
Ans: There are two ways to do this.
Ans: win32_computersystem. This can be used as follows:
PS C:\> $server = gwmi -cl win32_computersystem
PS C:\> $server.SystemType X86-based PC
Ans: When you add a variable to a double-quoted string, PowerShell replaces the variable name by its value. This feature is called variable interpolation.