Waa maxay PWSH.EXE? Liiska PWSH syntax ee aad isticmaali karto

PowerShell waa mid ka mid ah aaladaha qoraalka ugu awoodda badan ee Microsoft ay abuurtay. Maqaalkan, waxaanu ku wadaagi doonaa waxa PWSH.exe , iyo liiska muhiimka ah ee PWSH syntax . Waxaan hubaa in qaar badan oo ka mid ah adeegsigu ay isticmaaleen Windows PowerShell , laakiin PWSH hadda waa qalab qoraal ah oo iskutallaab ah oo ka shaqeeya Windows , macOS, iyo Linux . Si kastaba ha ahaatee, laguma taageero WSL ie Windows Subsystem -ka Linux , iyo isku dayga lagu dejiyo PWSH sida qolofka gelitaanka waxay u horseedi doontaa WSL aan degganayn .

Waa maxay PWSH.EXE?

PWSH

Kahor intaanan bilaabin, aan sifeyno hal tafatir. PWSH.EXE waa magaca cusub ee PowerShell . Tan iyo nooca 6 waxaa loo yaqaan PowerShell Core . Markii hore waxaa loogu magac daray powershell.exe oo ay tahay inaad ku aragtay Windows (nooca 5.1). La yaab ma leh mar kasta oo aad PowerShell ka bilowdo Windows , waxaad helaysaa farriin:

“Try the new cross-platform PowerShell https://aka.ms/pscore6.”

Waxaad ka akhrisan kartaa farqiga u dhexeeya PowerShell iyo PowerShell Core.(difference between PowerShell and PowerShell Core.)

Si degdeg ah maanta, PowerShell waxay gaartay nooca 7(PowerShell has reached version 7) oo ah isbeddel weyn marka loo eego nooca 6 oo adeegsada .NET Core 3 halkii uu ka isticmaali lahaa . Net Framework . Haddii aad rabto inaad tijaabiso, baro sida loogu rakibo PowerShell 7.0 Windows 10.(how to install PowerShell 7.0 on Windows 10.)

Falanqaynta PWSH ee muhiimka ah

-File | -f: Haddii aad amar ku leedahay faylka qoraalka, waxaad u isticmaali kartaa gelis ahaan. Waxaad sidoo kale u doodi kartaa faylasha marka ay khuseyso.

pwsh -File .\test.ps1 -TestParam $env:windir

-Command | -c : Isticmaal kan si aad ufuliso amar ama ScriptBlock . ScriptBlock waa hawlo loo dejiyay oo ku lifaaqan {}

pwsh -Command {Get-WinEvent -LogName security}

ama

@'
"in"

"hi" |
% { "$_ there" }

"out"
'@ | powershell -NoProfile -Command -

-EncodedCommand | -e | -ec : Isticmaal tan marka ay jirto baahi loo qabo in la isticmaalo calaamado xigasho oo adag ama xargo-duuban.

$command = 'dir "c:\program files" '
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)
pwsh -encodedcommand $encodedCommand

-Login | -l: Linux iyo macOS, waxay ku bilaabataa PowerShell sidii qolof gal (PowerShell)ah(Linux) , adoo isticmaalaya / bin / sh si loo fuliyo profiles galitaanka sida /etc/profile iyo ~/.profile. Ma khusayso Windows .

Waa inaad xaqiijisaa jidka saxda ah ee ku hoos qoran /etc/shells. Waxaad isticmaali kartaa  utility chsh si aad u dejiso qolofka isticmaalahaaga hadda pwsh.

chsh -s /usr/bin/pwsh

-SettingsFile | -goobaha

Haddii aad rabto in aad ku qorto goobaha caalamiga ah ee goobaha mashruuca maxaliga ah, markaa waxaad qeexi kartaa faylka dejinta adoo isticmaalaya doorashadan. Dejinta nidaamka-ballaaran ayaa laga helayaa powershell.config.json.

pwsh -SettingsFile c:\myproject\powershell.config.json

Liiska PWSH oo dhammaystiran

pwsh[.exe]
[[-File] <filePath> [args]]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
[-ConfigurationName <string>]
[-CustomPipeName <string>]
[-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>]
[-InputFormat {Text | XML}]
[-Interactive]
[-Login]
[-MTA]
[-NoExit]
[-NoLogo]
[-NonInteractive]
[-NoProfile]
[-OutputFormat {Text | XML}]
[-SettingsFile <SettingsFilePath>]
[-STA]
[-Version]
[-WindowStyle <style>]
[-WorkingDirectory <directoryPath>]

pwsh[.exe] -h | -Help | -? | /?

Haddii aad u baahan tahay faahfaahin dheeraad ah, waxaad booqan kartaa docs.microsoft.com.



About the author

Waxaan ahay injineer software iyo khabiir Windows 10 ah. Waxaan leeyahay waayo-aragnimo ka badan laba sano oo ku saabsan la shaqaynta casriga ah, windows 10, iyo Microsoft Edge. Diiradayda ugu weyn waa ka dhigista aaladahaagu kuwo si ka wanaagsan oo degdeg ah u shaqeeya. Waxaan ka shaqeeyay mashaariic kala duwan shirkado ay ka mid yihiin Verizon, Imac, HP, Comcast, iyo kuwo kale oo badan. Sidoo kale waxaan ahay macalin shahaado ka haysta tababarka daruuraha Microsoft Azure.



Related posts