Powershell

Editor:

Du vil starte Windows PowerShell ISE
Fra cmd eller powershell skriv: powershell_ise.exe

Eller lag en shortcut fra:
C:\windows\system32\WindowsPowerShell\v1.0\powershell_ise.exe

Her er et eksempel på et powershell script som kopierer filer:

#Script to backup Worlds in Minecraft
cls
‘Kopierer alle Minecreaft verdener og legger dem i en mappe med dato og klokkeslett’
$FolderNameWithDateAndTime = Get-Date -format “yyyyMMdd HH_mm_ss”
$SourceFolder = ‘c:\temp’
$DestinationFolder = Join-Path ‘c:\temp2’ $FolderNameWithDateAndTime
echo “Kopierer fra : ” $SourceFolder “til” $DestinationFolder
Copy-Item $SourceFolder $DestinationFolder -Recurse
# If running in the console, wait for input before closing.
if ($Host.Name -eq “ConsoleHost”)
{
Write-Host “Press any key to continue…”
$Host.UI.RawUI.FlushInputBuffer()
# Make sure buffered input doesn’t “press a key” and skip the ReadKey().
$Host.UI.RawUI.ReadKey(“NoEcho,IncludeKeyUp”) > $null
}

Lag en bat fil som kan starte powershell scriptet:

@ECHO OFF
rem Pass på at du ikke legger noen ekstra spacer bak linjene som angir filen!
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%CopyMineCraftStuff.ps1
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command “& ‘%PowerShellScriptPath%'”;

 

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment