Preparation Questions for mid-term exam @University of Puthisastra, Year 4-Sem I

Prepare questions for mid term

1. What if you wanted to filter a list of processes that started with s* and with e*? Would you use Where-Object or -Name?

You would use Where-Object like this Get-Process|Where-Object{$_.Name –like “s*” –or $_.Name –like “e*”}. Using –Name doesn’t support regular expressions for a value.

2. When working with remote services, are there any advantages in using the –Name parameter versus using Where-Object?

Yes, the advantage of using –Name is that it has an effect similar to filtering. With something like Get-Service –Comp LON-DC1 –Name “a*”, only the services that start with “a” are retrieved. If this was done instead Get-Service –Comp LON-DC1|Where-Object{$_.Name –like “a*”}, in this case, all of the services from the remote machine are retrieved and are processed locally as they are passed to Where-Object.

3. How might sorting work with numbers versus strings?

It will depend on what type of object is being sorted. Even a number can be treated as a string. Consider this example: 1,"11",2,"33",3|sort. The output will be 1,11,2,3,33 because PowerShell has treated all the entries as string objects.

4. Can you think of other delimiters you may want to use with Export-Csv?

Other examples could be “|” and “;”.

5. Is there a difference between saving objects to a variable versus saving them to XML formatted file?

One thing XML formatted files are useful for, is being able to actually save the information of objects to disk, and even possibly transferring the information to another system.

6. Thinking about objects having properties and methods, if an object is saved to a file, is anything lost?

One of the disadvantages of files versus variables is that even when the file is imported, the methods of the original object are basically lost.

7. What might interfere with doing any kind of query of a remote computer?

Network firewalls, and even client side firewalls can interfere with remote queries like Get-Service and Get-Process.

8. Do all cmdlets accept pipeline input like New-ADUser?

No, not all cmdlet parameters have been programmed this way. To check whether a parameter accepts pipeline input can be determined by checking Get-Help with the –Full switch.

9. What is the advantage of a cmdlet parameter that accepts pipeline input?

A definite advantage is the shorter amount of typing required when the input can be read from any kind of input.

10. Before stopping a process, could a check be made to only stop the process if it was using more than a certain amount of physical or virtual memory?

Yes, simply using the filter cmdlet Where-Object in the pipeline could easily verify the current memory status. That would be useful in a script that is running regularly to check whether a process is having memory problems, and terminate it once it goes over a certain value.

11. Where can the $_ placeholder be used?

This placeholder is used to replace the current pipeline object, common in cmdlets like Where-Object and ForEach-Object.

12. What cmdlet do you use to remove selected objects from the pipeline?

Where-Object is used to filter entire objects out of the pipeline.

13. What kind of object is output by Select-Object when you specify property names?

The object that is output is the same object that was input into Select-Object, but with only those specified property names.

14. How do you list WMI classes in a specific namespace?

Call Get-WmiObject passing the namespace into the Namespace parameter and using the List switch parameter. E.g. Get-WmiObject –Namespace root\default -List

15. What is the WMI class to retrieve operating system information called?


16. How do you use a server-side filter when using Get-WmiObject?

Pass a WMI expression to filter the data to the remote computer you are working with by using the Filter parameter.

17. Where is the best place to use filtering criteria with WMI?

A best practice is to “filter left,” that is, to specify filtering criteria as far to the left of the Windows PowerShell command line as possible. When you can filter by using a –filter parameter of a cmdlet, doing so is preferable to using the Where-Object cmdlet for the same filtering task.

18. When can alternate credentials be used with WMI connections?

When connecting to remote computers. It is not possible to use alternate credentials when connecting to a local WMI provider.

19. What protocol does WMI use, and how can you enable it to pass through a local firewall?

WMI rides atop the RPC protocol. A local computer’s Windows Firewall can be configured to pass its traffic by enabling the Remote Management dynamic exception.

20. Which common Active Directory cmdlet parameter is used to limit search results to matches based on attributes?


21. Which common Active Directory cmdlet parameter is used to specify the attributes that you want in your query results? Properties

22. How do you add the Active Directory functionality to your PowerShell session?

ipmo ActiveDirectory

23. How can you see a list of all attributes that are available for an Active Directory object?

Get-ADUser -Filter * -Properties * -ResultSetSize 1 | fl *

24. Which parameter can be used to limit the total number of objects returned in an Active Directory query? ResultSetSize

25. On which operating systems are the Active Directory cmdlets available?

Windows 7 and Windows Server 2008 R2

26. Which module contains the Active Directory cmdlets? The ActiveDirectory module

27. What is the purpose of an Active Directory PSDrive?

It is primarily used as an object that contains credentials for running Active Directory-related cmdlets.

28. Which drive must be active in order to use New-PSDriveto map a new drive to Active Directory? The AD: drive must be active.

29. If you send a script to another user with Windows 7 or Windows Server 2008 R2, will they be able to run the script? Is PowerShell included with these versions? Is it included with older Windows operating system versions?

Yes, both Windows 7 and Windows Server 2008 R2 come with PowerShell v2 by default. By default their execution policy is set to Restricted though, so a user won’t be able to immediately run any scripts without changing the execution policy.

30. If you send a script to another user, how can they incorporate that so that it automatically runs every time PowerShell is opened?

By adding if to the profile, they can make PowerShell load the script every time it is opened.

31. Is there a way to specify a default value for parameters in the param statement?

Yes, for example, using the syntax param([string]$my=”value”). In that case, unless a different value is provided when invoking the script, $my will be assigned the string “value”.

32. What execution policy requires that remote scripts have a digital signature? RemoteSigned

33. What are the advantages of a parameterized script?

Reuse. Replacing variable information with parameters allows the script to be run with varying information, in a more structured fashion.

34. You have started a PowerShell console and have started a couple of background jobs. What happens to the background jobs if they are still running and the main console is closed?

The background jobs will basically stop running completed and all the information they may contain will be lost.

35. If you have two or more PowerShell consoles open, and start a background job in one console, can you access the job from the other console?

No, jobs are tied directly to the console that started them and cannot be accessed by any other consoles.

37. Is there any limit to the number of remote sessions can be run?

Basically the only limit is availability of resources on all the systems involved in PowerShell remoting. There is however a –ThrottleLimit property available for Invoke-Command which limits the number of simultaneous child jobs that can run at any one time.

38. If I use Invoke-Command from one console and start it as a background job, can other consoles on the same server also see the background jobs and access their information directly?

No, all the background jobs are basically attached to the console that they were initiated from. You can, however, share information between consoles, but it requires using some intermediary, like saving the output from a job to a text or XML file, and importing that file into the other console.

39. What is the primary difference between Start-Job and Invoke-Command (used with its –AsJob parameter)?

Start-Job is for local jobs. Invoke-Command is for remote computer jobs.

40. Will implicit remoting work if the remote computer does not have WinRMenabled?


41. What command would disable Remoting on the local computer?


43. What kind of object is output by Measure-Object?

A measurement object

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s