This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Powershell”.
1. Which of the following command is used to get child items in powershell?
a) Get-Child
b) Set-Alias
c) Get-Command
d) Get-ChildItem
View Answer
Explanation: Get-ChildItem is used to get the contents of a folder or registry key.
2. Point out the wrong statement.
a) Get-Command retrieve basic information about a command
b) Trace-Command trace an expression or command
c) Get-Content delete content from a file
d) None of the mentioned
View Answer
Explanation: Clear-Content remove content from a file/item.
3.___________ convert object properties into CSV objects.
a) ConvertFrom-CSV
b) Convert-CSV
c) ConvertFromCSV
d) All of the mentioned
View Answer
Explanation: ConvertFrom-CSV convert object properties (in CSV format) into CSV objects.
4. What will be the output of the following code?
PS C:\bin> notepad hello.ps1
a) Text editor with “Hello world” scripted
b) Text editor with “Hello” scripted
c) Text editor with no script
d) All of the mentioned
View Answer
Explanation: Code will bring up your text editor window so you can begin scripting with zero characters.
5. Point out the wrong statement.
a) The first PowerShell cmdlet every administrator should learn is Get-Command
b) Get-Event is used to find events in the PowerShell event queue
c) Limit-EventLog is used to limit the size of the event log
d) None of the mentioned
View Answer
Explanation: The first PowerShell cmdlet every administrator should learn is Get-Help.You can use this command to get help with any other command.
6. Syntax for viewing the methods and properties we can pipe our output to Get-Member by ______________
a) Get-Process
b) Get-Member
c) Get-Process | Get-Member
d) All of the mentioned
View Answer
Explanation: The Get-Process cmdlet gets the processes on a local or remote computer.
7. Unrestricted execution policy can be set up in SQL Server can be done using __________
a) Set-ExecutionPolicy Unrestricted
b) Set-Policy Unrestricted
c) Set-Policy Unrestricted
d) None of the mentioned
View Answer
Explanation: Unrestricted removes all restrictions from the execution policy.
8. Code for creating an HTML report that lists the name of each service along with its status is __________
a) Get-Ser | ConvertTo-HTML -Property Name, Status > C:\services.htm
b) Get-Service | Property Name, Status > C:\services.htm
c) Get-Service | ConvertTo-HTML -Property Name, Status > C:\services.htm
d) All of the mentioned
View Answer
Explanation: ConvertTo-HTML is helpful to create a report so that you can send to someone.
9. Which of the following code list all the log files in Window?
a)
snippet Clear-Host $Directory = "C:\Windows\"` -ErrorAction SilentlyContinue
b)
snippet Clear-Host $Files = Get-Childitem $Directory -recurse -Include *.log ` -ErrorAction SilentlyContinue
c)
snippet Clear-Host $Directory = "C:\Windows\" $Files = Get-Childitem $Directory -recurse -Include *.log ` -ErrorAction SilentlyContinue
d) All of the mentioned
View Answer
Explanation: -Include and -recurse can list all the log files under the Windows folder.
10. Which of the following code snippet will return output as false?
a)
PS C:\bin> $myData = "01/28/1969" PS C:\bin> $mydata -isdata[string]
b)
PS C:\bin> $myData = "01/28/1969" PS C:\bin> $mydata -isnot [string]
c)
PS C:\bin> $myData = "01/28/1969" PS C:\bin> $mydata -NOT [string]
d)
PS C:\bin> $myData = "01/28/1969" PS C:\bin> $mydata -isString [string]
Explanation: -is and -isnot are used to compare a variable or data literal with a given type.
Sanfoundry Global Education & Learning Series – SQL Server.
To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Information Technology Books
- Check SQL Server Books
- Practice Programming MCQs
- Apply for Programming Internship