Skip to main content

Powershell Commands For Gurus/Hackers

Becoming a computer guru simply means doing what your mates can not do on the computer system and not just doing it, but doing it very fast. The only way you could work very fast on a computer is by using command prompt or any other kind of command line program. You can delete a whole file in no time and no one except the smart people like you would know how you did it. Most people shy away from command prompt because they have the impression that commnad prompt is very hard and requires someone to have Jimmy Neutron's brain in order to use it. But, in this post, I am telling you that command prompt isn't as hard as it looks, and to clear my point on that we are going to be running some cammands using a windows built-in tool known as Powershell.
Note: Powershell can be found on computers with Microsoft Windows 7 and higher.
To start, go to start menu, in the search box, type "Powershell" and Windows Powershell will be filtered out. Right click on it and click Pin To Taskbar so that you can always start it up from the Taskbar without having to search for it every time you want to use it.
Now click to open it, When it is opened, you are ready to start using it for wonders. You should see a screen similar to this:



Now the commands we are going to be treating in this post are Get-Location and Set-Location which are the basic folder navigating commands. When navigating folder systems in Windows Explorer, you usually have a specific working location - namely, the current open folder. Items in the current folder can be manipulated easily by clicking them. For command-line interfaces such as Cmd.exe on Windows and Terminal on Linux and other OS, when you are in the same folder as a particular file, you can access it by specifying a relatively short name, rather than needing to specify the entire path to the file. The current directory is called the working directory.
Windows PowerShell uses the noun Location to refer to the working directory, and implements a family of cmdlets to examine and manipulate your location.

Getting Your Current Location (Get-Location)
To determine the path of your current directory location, enter the Get-Location command:
PS> Get-Location
Path
----
C:\Documents and Settings\PowerUser

Note: The Get-Location cmdlet is similar to the pwd command in the BASH shell. The Set-Location cmdlet is similar to the cd command in Cmd.exe.

Setting Your Current Location (Set-Location)
The Get-Location command is used with the Set-Location command. The Set-Location command allows you to specify your current directory location.
PS> Set-Location -Path C:\Windows
After you enter the command, you will notice that you do not receive any direct feedback about the effect of the command. Most Windows PowerShell commands that perform an action produce little or no output because the output is not always useful. To verify that a successful directory change has occurred when you enter the Set-Location command, include the -PassThru parameter when you enter the Set-Location command:
PS> Set-Location -Path C:\Windows -PassThru
Path
----
C:\WINDOWS
The -PassThru parameter can be used with many Set commands in Windows PowerShell to return information about the result in cases in which there is no default output.
You can specify paths relative to your current location in the same way as you would in most UNIX and Windows command shells. In standard notation for relative paths, a period (.)represents your current folder, and a doubled period (..) represents the parent directory of your current location.
For example, if you are in the C:\Windows folder, a period (.)represents C:\Windows and double periods (..) represent C:. You can change from your current location to the root of the C: drive by typing:
PS> Set-Location -Path .. -PassThru
Path
----
C:\
The same technique works on Windows PowerShell drives that are not file system drives, such as HKLM:. You can set your location to the HKLM\Software key in the registry by typing:
 PS> Set-Location -Path HKLM:\SOFTWARE -PassThru

Path
----
HKLM:\SOFTWARE
You can then change the directory location to the parent directory, which is the root of the Windows PowerShell HKLM: drive, by using a relative path:
PS> Set-Location -Path .. -PassThru

Path
----
HKLM:\
You can type Set-Location or use any of the built-in Windows PowerShell aliases for Set-Location (cd, chdir, sl). For example:
cd  -Path C:\Windows
chdir -Path .. -PassThru
sl -Path HKLM:\SOFTWARE -PassThru
Saving and Recalling Recent Locations (Push-Location and Pop-Location)
When changing locations, it is helpful to keep track of where you have been and to be able to return to your previous location. The Push-Location cmdlet in Windows PowerShell creates an ordered history (a "stack") of directory paths where you have been, and you can step back through the history of directory paths by using the complementary Pop-Location cmdlet.
For example, Windows PowerShell typically starts in the user's home directory.
 PS> Get-Location

Path
----
C:\Documents and Settings\PowerUser

Note: The word stack has a special meaning in many programming settings, including .NET Framework. Like a physical stack of items, the last item you put onto the stack is the first item that you can pull off the stack. Adding an item to a stack is colloquially known as "pushing" the item onto the stack. Pulling an item off the stack is colloquially known as "popping" the item off the stack.
To push the current location onto the stack, and then move to the Local Settings folder, type:
 PS> Push-Location -Path "Local Settings"
You can then push the Local Settings location onto the stack and and move to the Temp folder by typing:
PS> Push-Location -Path Temp
You can verify that you changed directories by entering the Get-Location command:
PS> Get-Location

Path
----
C:\Documents and Settings\PowerUser\Local Settings\Temp
You can then pop back into the most recently visited directory by entering the Pop-Location command, and verify the change by entering the Get-Location command:
PS> Pop-Location
PS> Get-Location

Path
----
C:\Documents and Settings\me\Local Settings
Just as with the Set-Location cmdlet, you can include the -PassThru parameter when you enter the Pop-Location cmdlet to display the directory that you entered:
PS> Pop-Location -PassThru

Path
----
C:\Documents and Settings\PowerUser
You can also use the Location cmdlets with network paths. If you have a server named FS01 with a share named Public, you can change your location by typing
Set-Location \\FS01\Public
or
Push-Location \\FS01\Public
You can use the Push-Location and Set-Location commands to change the location to any available drive. For example, if you have a local CD-ROM drive with drive letter D that contains a data CD, you can change the location to the CDdrive by entering the Set-Location D: command.
If the drive is empty, you will get the following error message:
PS> Set-Location D:
Set-Location : Cannot find path 'D:\' because it does not exist.
When you are using a command-line interface, it is not convenient to use Windows Explorer to examine the available physical drives. Also, Windows Explorer would not show you the of the Windows PowerShell drives. Windows PowerShell provides a set of commands for manipulating Windows PowerShell drives, and we will talk more about this in the posts to come.
Enjoy your new guru skill and thanks for reading.



Comments

Popular posts from this blog

Microsoft will allow you to upgrade your pirated Windows 7 or 8 to full Windows 10 for little or no amount.

Microsoft's latest Operating System has been trending for a while now, while some are still contemplating on who gets a free upgrade from the two previous Microsoft's Operating Systems just like the company promised and who wouldn't, Microsoft has announced that the upgrade to Windows 10 would be free for genuine Windows 7 or 8 users and there is a good news for pirated Windows 7 or 8 users, they too might go to the Promised Land for free or pay a little fee.Hmmm..., with this in place, you can see how determined Microsoft is to pull everyone into its Windows 10 ecosystem. You know, when Windows 10 Technical Preview was first announced along with how it's going to operate (Windows as a Service), I thought Microsoft is finally kicking Windows Pirates out of business, but it seems Microsoft is giving them one more chance to own a genuine Windows, maybe Windows 10  is going to be "un-piratable" (let's just hope MS gets it right).Hahaha!...., before I forget,

HOW TO WRITE, COMPILE AND RUN C++ CODE ON LINUX KALI

This article is for hackers who want to develop a c++ program on Kali Linux without having to install any additional software. While some would tell you that you need to install an additional software or a compiler in order to develop a simple program in c++ on Kali Linux, I am going to show you how to develop a c++ program on this distro right out of box. Your Linux Kali comes pre-installed with a c++ compiler called g++ so we are going to write a C++ hello word code and compile it with this compiler. Before we get started, first open up terminal and run to verify if this compiler is installed on you machine: g++ -v if the compiler is pre-installed, you should get the version information of the compiler, otherwise, you should get an error. Now let's jump right in. In your terminal window, type in: nano MyCpp.cpp to create a c++ file and lunch it in nano editor for editing. When nano opens, type in the following c++ code and press Ctrl+x then y and then R

LOAN MANAGEMENT SYSTEM (My Project Idea)

There are many companies that specializes on giving loan to people; they make their profits by collecting interest on any money they lend out, and before a loan can be given to any customer, the customer must provide a collateral and some details such as:  contact details and a reference/guarantor. When the loan is finally given to the customer, they charge interest based on the the amount given to the customer for a given period of time which could be daily, weekly, monthly or yearly.  For example, a company could be collecting interest based on a particular amount for a given period of time like: $200,000 loan would have an interest tag of $2,000  per month until the money is returned, and $100,000 would have an interest of $1,000 per month until the money is returned.  In  addition, the customers need to know when the time for them to pay their interest comes e.g.  at the end of the month or the timing model with which the calculation is being made. Usually, these companies sends ou