Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.
2008-12-13
When you know about cmdlets and how to get help on them, the next thing is to learn how to use the window.All commands you type in are saved in the command buffer. The keys you use to access the buffer is:
– [Up] for the previous command in the buffer
– [Down] for the next command in the buffer
– [PgUp] for the first and [PgDn] for the last command in the buffer
If you want to move the cursor on the line you are editing for the moment, [Left] and [Right] moves the cursor sideways, [Home] takes you to the first character of the line and [End] takes you to the last one. If you hold [Ctrl] while pressing [Left] or [Right], you move one word at a time, instead of one character.
The [Tab] key is used to auto-complete a word. For example, if you type Write-O and press [Tab],Write-O will be replaced with Write-Output. To pick a command from the buffer, press [F7].
If you want to execute a script, you can create a text file that contains your commands, and execute that, just by entering the scripts path and name. If you want to execute a script (a text file with a ps1 ending) in the directory you’re currently in, and the script file name is “myscript.ps1”:
.\myscript.ps1
PowerShell might complain about the script not being signed. You can remove the requirements for signing by executing this command:
Set-ExecutionPolicy Unrestricted
To test this, create a new text file, type in any commands, for example:
$x=”Sven”
Write-Output $x
Then save it with ps1 file ending, and execute it, just by typing the path and the name of the file.
Categories: PowerShell
Tags: PowerShell
Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!
Leave a Reply