HackGh Community Forum

Log in

I forgot my password



Who Is Online?
Guests : 0
Hidden : 0
Registered : 0
Users Online :
Refresh View the whole list

Latest topics
» How To Get Free 3GB From Glo Network
Yesterday at 10:46 pm by Appietus16

» AIRTEL FREE BROWSING
Tue Aug 15, 2017 1:20 pm by akokono

» Instagram Account hacked
Sun Aug 06, 2017 7:17 pm by saudseidu

» AIRTEL DATA TRANSFER
Sat Aug 05, 2017 7:22 pm by kbasante

» Watch Free 2CTV on any Vodafone line for the month of July
Thu Aug 03, 2017 2:45 pm by WhIPL4$h

» Tricks on How To Download Paid Android Apps For Free
Thu Jul 20, 2017 11:28 am by franknart12

» Psiphon Pro v125 [Subscribed] Cracked APK
Thu Jul 20, 2017 9:29 am by franknart12

» NSS posts over 91,000 service personnel for 2017/2018
Thu Jul 13, 2017 3:00 pm by chinesta10

» Kotoko team bus involved in accident
Thu Jul 13, 2017 1:00 pm by chinesta10

» Airtel Sika kokoo promo
Sun Jul 09, 2017 12:18 pm by willspanner

Keywords

HackGh  keepCalmAndLoveHACKGH4Life  busy  browsing  5  4  cheat  2  3  Tigo  1  9  2000  6  free  unlocking  Unlimited  ghana  black  10  christian  8  7  dumsormuststop  11  30  

Top posting users this month
swiftblack
 
kbasante
 
Sannyz
 
WhIPL4$h
 
saudseidu
 
Appietus16
 
Awuah33
 
akokono
 



Free counters!
Staff Online
Staff Online
Members1993
Most Online179
Newest Member

You are not connected. Please login or register

 » Computer Tricks And Technology Tips » Pc ( Windows ) Tips & Downloads » 

How Windows PowerShell determines which command to run - Part 1

View previous topic View next topic Go down  Message [Page 1 of 1]

PhAnt0m

avatar
Administrator
Administrator
LONG DESCRIPTION

This topic explains how Windows PowerShell determines which command to run, especially when a session contains more than one command with thE same name. It also explains how to run commands that do not run by default, and it explains how to avoid command-name conflicts in your session.


COMMAND PRECEDENCE

When a session includes commands that have the same name, Windows PowerShell uses the following rules to decide which command to run. These rules become very important when you add commands to your session from modules, snap-ins, and other sessions.

If you specify the path to a command, Windows PowerShell runs the command at the location specified by the path. For example, the following command runs the FindDocs.ps1 script in the C:\TechDocs directory:

C:\TechDocs\FindDocs.ps1

As a security feature, Windows PowerShell does not run executable (native) commands, including Windows PowerShell scripts, unless the command is located in a path that is listed in the Path environment variable ($env:path) or unless you specify the path to the script file.

To run a script that is in the current directory, specify the full path, or type a dot (.) to represent the current directory. For example, to run the FindDocs.ps1 file in the current directory, type:

.\FindDocs.ps1

If you do not specify a path, Windows PowerShell uses the following precedence order when it runs commands:

1. Alias
2. Function
3. Cmdlet
4. Native Windows commands

Therefore, if you type "help", Windows PowerShell first looks for an alias named "help", then a function named "Help", and finally a cmdlet named "Help". It runs the first "help" item that it finds.

For example, assume you have a function named Get-Map. Then, you add or import a cmdlet named Get-Map. By default, Windows PowerShell runs the function when you type "Get-Map". When the session contains items of the same type that have the same name, such as two cmdlets with the same name, Windows PowerShell runs the item that was added to the session most recently.

For example, assume you have a cmdlet named Get-Date. Then, you import another cmdlet named Get-Date. By default, Windows PowerShell runs the most-recently imported cmdlet when you type "Get-Date".

HIDDEN and REPLACED ITEMS

As a result of these rules, items can be replaced or hidden by items with the same name. Items are "hidden" or "shadowed" if you can still access the original item, such as by qualifying the item name with a module or snap-in name.

For example, if you import a function that has the same name as cmdlet in the session, the cmdlet is hidden (but not replaced)because it was imported from a snap-in or module. Items are "replaced" or "overwritten" if you can no longer access the original item.

For example, if you import a variable that has the same name as a variable in the session, the original variable is replaced and is no longer accessible. You cannot qualify a variable with a module name. Also, if you type a function at the command line and then import a function with the same name, the original function is replaced and is no longer accessible.


RUNNING HIDDEN COMMANDS

You can run particular commands by specifying item properties the distinguish the command from other commands that might have the same name. You can use this method to run any command, but it is especially useful for running hidden commands. Use this method as a best practice when writing scripts that you intend to distribute because you cannot predict which commands might be present in the session in which the script runs.

QUALIFIED NAMES

You can run commands that have been imported from a Windows PowerShell snap-in or module or from another session by qualifying the command name with the name of the module or snap-in in which it originated. You can qualify commands, but you cannot qualify variables or aliases.

For example, if the Get-Date cmdlet from the Microsoft.PowerShell. Utility snap-in is hidden by an alias, function, or cmdlet with the same name, you can run it by using the snap-in-qualified name of the cmdlet:

Microsoft.PowerShell.Utility\Get-Date

To run a New-Map command that was added by the MapFunctions module, use its module-qualified name:

MapFunctions\New-Map

To find the snap-in or module from which a command was imported, use the following Get-Command command format:

get-command | format-list -property Name, PSSnapin, Module

For example, to find the source of the Get-Date cmdlet, type:


get-command get-date | format-list -property Name, PSSnapin, Module

Name : Get-Date
PSSnapIn : Microsoft.PowerShell.Utility
Module :

Part 2 to follow......


------------------------------------------------



Hacking Is My Religion ..Hackers Inside



[Useful Links]
Free Browsing
Betting Hack
Buy A Website
Reset Your Password
Free Cheat Book
View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum