Powershell Tutorial Online

Powershell Interview Questions

Here are some sample PowerShell interview questions.
These are the kinds of questions that could be asked to gauge one's basic literacy and comfort level with PowerShell.

Basic literacy. Describe the following:
a. What is PowerShell? Why is it called a shell?
b. How does PowerShell differ previous Windows scripting techniques, such as CMD/batch files, VBScript, etc.?
c. What is a cmdlet?
d. What is meant when it's said that Powershell is "object-based"?
e. What is the pipeline? How is it useful?

Get the amount of free space on the C drive.
Ans:- Using WMI is an option

How to automate Internet Explorer to open a web site using PowerShell?

Please below three simple steps to open Internet Explorer a

$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true

How to run a PowerShell script?
Launch PowerShell
Navigate to the directory where the script lives

 PS> cd C:\test\ (enter)

Execute the script:
 PS> .\test_script.ps1 (enter)

There is alternate way to run powershell script using “POWERSHELL_ISE”.
Please see below option.

How to prepare window 7 bootable Disc using powershell?
Ans : Coming Soon..

Is PowerShell ready to replace my cygwin shell on Windows?
PowerShell is defiantly looks powerful tool for windows.
The person who worked in heterogeneous environments Linux, Solaris and Mac OS X and cygwin.
Can differentiate better way. It is nice and more powerful tool environment seems to have been thought out much more than Unix shells as it use of objects instead of text streams.
Powershell is more powerful than the standard built-ins of the Unix shells.
Note: - Using objects is a paradigm shift as compare to other environments and it avoids the whole re-parsing at each step where structured data is involved.

How to use powershell to download old version of package with nuget?
The powershell command Install-Package has a Version argument that can be used to specify a specific version.

Get-Package -ListAvailable -Filter Autofac –AllVersions
By pressing tab after the version option in the Install-Package command, you get a list of the latest available versions.
Install-Package Autofac -Version 1.2.0

How do you count the lines of code in a Visual Studio solution using powershell script?
Specify project folder path and below comments to measure the count lines of code

PS>cd D:\NineOptions\SSRSService\
PS>(dir -include *.cs,*.xaml,*.cpp,*.h,*.idl,*.asmx -recurse | select-string .).Count

PowerShell “execution of scripts is disabled on this system.”
There two ways to solve the issue. As bydefault powershell –ExecutionPolicy is restricted.
You may change it to either of 4 available options
1. Restricted
2. Unrestricted
3. Signed
4. RemoteSigned
Set-ExecutionPolicy RemoteSigned
Or you can bypass the execution policy for particular ps1 file.
powershell -ExecutionPolicy ByPass -File script.ps1

PowerShell to build App.Config separately based on project.
You can get more detail about xmlpreprocess at below link.
Managing Properties
Create xml with each environment details.
A spreadsheet can be used to manage the properties for all of your environments in one place.
Command Line

    Usage: XmlPreprocess.exe [@argfile] [/input|i:] [/output|o:]
       [/settings|s:] [/define|d:] [/clean|c] [/quiet|q] [/validate|v]
       [/validateSettingsExist|vs] [/validateXmlWellFormed|vx] [/fixFalse|f]
       [/environment|e:] [/spreadsheet|x:] [/database|db:]
       [/custom|cx:] [/list|l] [/property|p:] [/delimiters|t:]
       [/environmentRow|er:] [/firstValueRow|vr:]
       [/settingNameCol|nc:] [/defaultValueCol|dc:]
       [/environmentFile|ef:] [/noDirectives|n] [/tokenStart|ts:]
       [/tokenEnd|te:] [/countReportFile|cr:] [/noLogo] [/help|?|h] [/version|v]
how to prepare xml setting please go to home page and find the more detail..


Powershell script for deploying configuration setting to actual web.config for each environment.

 foreach ($Env in $EnvList)
 XmlPreprocess.exe /v /f /nologo /i "web.config" /s "SettingConfigs.xml" /e $remoteserver /o "$OutputPath\web.config"

If you need more details please do reach us.
How to access argument list for scriptblock? ArgumentList is based on use with scriptblock commands, like:
 $xArgvalue= arg[0]
 $yArgvalue= arg[1]
} -ArgumentList $x,$y