Presentation is loading. Please wait.

Presentation is loading. Please wait.

POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access.

Similar presentations


Presentation on theme: "POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access."— Presentation transcript:

1 POWERSHELL BASICS

2 BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access to the COM (Component Object Model) and WMI (Windows Management Instrumentation)  The functions (lightweight commands) that PowerShell utilizes to complete certain tasks are called cmdlets (command-lets)

3 BACKGROUND (CONTINUED)  Cmdlets are not standalone executables; they are instances of.NET framework classes  PowerShell syntax is case insensitive

4 FIRST SCRIPT  Suppose you wanted to query a list of currently running processes on a system. The following command will do just that:  Get-Process  To sort the list of processes, use the pipeline ` | ` to pass the output to the Sort-Object cmdlet (or Sort)  You can select certain fields of the output by piping the output and passing it using select

5 FIRST SCRIPT (RUNNING THE SCRIPT)  There are various ways a PowerShell script can be run  Command line  Type in the path of the script  If the current directory is the same as the script, the filename must be preceded with “.\” or “./”  File Explorer

6 FIRST SCRIPT (RUNNING THE SCRIPT)  Based on the ExecutionPolicy setting on the system, this may need to be overridden in order to be able to run scripts  To change this setting, you must be an administrator  You can bypass this setting without actually changing the setting by writing a one-line batch file that calls PowerShell to run the script using certain arguments

7 ACTIVE DIRECTORY  PowerShell, being native to the Windows environment, is a powerful language to use when interacting with AD objects  The user can process information more quickly than some GUI utilities

8 ACTIVE DIRECTORY (EXAMPLES)  Query all AD users in the domain:  Get-ADUser –Filter *  Get AD users based on a filter:  Get-ADUser -Filter 'name -like "parsa*“’  Notice the wildcard at the end of the filter  Filter users based on department:  Get-ADUser –Filter ‘office –like “* *”’

9 ACTIVE DIRECTORY (EXAMPLES, CONTINUED)  You can query AD computer objects that have been created or modified by a certain date  $d = (Get-Date).addDays(-1)  Variable $d is assigned the value of one day before the current date

10 UPDATING COMPUTER SCRIPT ./updateWorkstation.bat ./updateWorkstation.ps1

11 GET AD COMPUTERS WHEN CREATED SCRIPT ./getComputerModBy.bat ./getComputerModBy.ps1

12 BACKUP USERS SCRIPT ./backup.bat ./backup.ps1

13 GET COMPUTER NAME AND RAM SCRIPT ./getComputerName.bat ./getComputerName.ps1

14 SOURCES  http://windowsitpro.com/powershell/top-10-active-directory- tasks-solved-powershell http://windowsitpro.com/powershell/top-10-active-directory- tasks-solved-powershell  https://msdn.microsoft.com/en-us/library/ms714395(v=vs.85).aspx


Download ppt "POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access."

Similar presentations


Ads by Google