Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Powers-shell Interview questions #25

Closed
luhuimao opened this issue Oct 8, 2018 · 0 comments
Closed

Windows Powers-shell Interview questions #25

luhuimao opened this issue Oct 8, 2018 · 0 comments
Assignees

Comments

@luhuimao
Copy link
Contributor

luhuimao commented Oct 8, 2018

(1) What does the powershell command “Test-Path c:\PowerShell.xlsx” means ()
A. Executing “c:\PowerShell.xlsx”.
B. Open file “c:\PowerShell.xlsx”.
C. Delete file “c:\PowerShell.xlsx”.
D. Check file “c:\PowerShell.xlsx” exist or not.

(2) How to move a file to other place in powershell?
A. Move c:\PowerShell.xlsx d:\PowerShell.xlsx.
B. mv c:\PowerShell.xlsx d:\PowerShell.xlsx.
C. copy c:\PowerShell.xlsx d:\PowerShell.xlsx.
D. Move-Item c:\PowerShell.xlsx d:\PowerShell.xlsx.

(3) How to open a executable file in powershell?
A. run c:\Windows\System32\notepad.exe
B. open c:\Windows\System32\notepad.exe
C. execute c:\Windows\System32\notepad.exe
D. Invoke-Item c:\Windows\System32\notepad.exe

(4) How to output the current time in command promt ?
A. print time.
B. print date.
C. echo %time%
D. echo %date%

(5) How to executing multiple commands in one command line in batch file?
A. command1 : command2 : command3: …
B. command1 & command2 & command3& …
C. command1 @ command2 @ command3@ …
D. command1 ! command2 !: command3!: …

(6) How to call a batch file?
A. Run a.bat
B. Invoke a.bat
C. Execute a.bat
D. Call a.bat

(7) The result of the following command is ()
@echo off
set /a num1=20
set /a num2=15
if %num1% gtr %num2% echo %num1%greater%num2%
if %num1% EQU %num2% echo %num1%equal%num2%
if %num1% LSS %num2% echo %num1%less%num2%
A. 20 greater 15
B. 20 less 15
C. 20 equal 15
D. 20

(8) What is Powershell Scripting?
A. Type the commands in a text editor
B. Save the file with .ps1 extension
C. Execute the file in PowerSehll
D. All of these

(9) What are the types of format commands that can be used to Format data?
A. Format-Wide
B. Format-List
C. Format-Table
D. All of the above

(10) What are the types of brackets used in PowerShell?
A. Parenthesis Brackets ()
B. Braces Brackets {}
C. Square Brackets []
D. All of the above mentioned

(11) What are the ways to find all the sql services are on one server in PowerShell?
A. get-wmiobject win32_service l where-object {$_name-like “sql”}
B. get-service sql
C. Both A and B
D. None

(12) How do you find the computer name in PowerShell ?
A. hostname
B. $env:COMPUTERNAME
C. Get-ItemProperty -Path “HKLM:SYSTEMCurrentControlSetControlComputerNameActiveComputerName” -Name “ComputerName” | Select-Object -Property Computername
D. All of them

(13) How do you find the free space of C: drive in GBs?
A. Get-PSDrive –Name C | ForEach-Object {[math]::round($.free/1GB)}
B. Get-PSDrive –Name C | % {[math]::round($.free/1GB)}
C. Get-PSDrive –Name C | Select-Object -Property free | % {[math]::round($_.free/1GB)}
D. All of them

(14) How to find top 100 processes that are consuming memory more than 100MB and export the list of processes to a CSV file?
A. Get-Process | where pm -gt 100MB | select -First 100 | Sort pm -Descending | Export-Csv C:TempProcess-100MB-Memmory.csv
B. Get-Process | where pm -gt 100MB | select -First 100 | Sort pm -Descending
C. A and B
D. None

(15) How do you measure the time taken for execution of a PowerShell command?
A. Measure-Command { Get-WmiObject -Class win32_service | where-object { ($.StartMode -eq “Manual”) -and ($.State -eq “Running”) } } | select TotalSeconds | ft -a
B. Measure-Command { Get-WmiObject -Class win32_service -Filter “StartMode=’Manual’ and State=’Running'” } | Select TotalSeconds | ft -a
C. A and B
D. None

@caesarchad caesarchad changed the title Windows Powers-hell Interview questions Windows Powers-shell Interview questions Dec 5, 2018
@lsf1001 lsf1001 closed this as completed Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants