Sida loo abuuro loona socodsiiyo faylka qoraalka PowerShell Windows 11/10

Qoraalku waa kaliya ururinta amarada lagu kaydiyay faylka qoraalka (adoo isticmaalaya .ps1 kordhinta gaarka ah) kaas oo PowerShell uu fahmo oo u fuliyo si isku xigta si uu u fuliyo falal kala duwan. Maqaalkan, waxaan ku qeexi doonaa habka ku lug leh sida loo abuuro loona maamulo faylka qoraalka PowerShell Windows 11/10 .

PowerShell waa aalad talis ah oo ay Microsoft u qaabaysay si ay u socodsiiso amarada iyo qoraallada si ay u beddesho goobaha oo ay u toosiso hawlaha. Qaab ahaan, waxay la mid tahay Command Prompt . Si kastaba ha ahaatee, PowerShell waa interface-line interface ka karti badan ( CLI ) kaas oo bixiya qalab aad u ballaaran iyo dabacsanaan iyo xakameyn badan. Sidoo kale, si ka duwan Command Prompt, PowerShell ayaa laga heli karaa Windows , macOS, iyo Linux .

Si aad u aragto sida loo abuuro loona socodsiiyo faylka qoraalka PowerShell Windows 11/10 , raac tilmaamaha mid kasta oo ka mid ah hawlaha sida ku cad qaybaha kala duwan.

Sida loo abuuro faylka qoraalka PowerShell

Abuur oo socodsii faylka qoraalka PowerShell

On Windows 11/10 , waxaad abuuri kartaa faylalka qoraalka PowerShell adigoo isticmaalaya tafatire kasta ama (PowerShell)ISE ( Integrated Scripting Environment ) console. Si kastaba ha ahaatee, ikhtiyaarka la door bidayo ee lagu dhisayo qoraallada hore u socda waa in la isticmaalo tifaftiraha Code Studio Code(Studio Code) oo leh kordhinta PowerShell .

Visual Studio Code — oo sidoo kale loo yaqaano VS Code — waa bilaash oo la bixin karo tifaftiraha koodka iskutallaabta ah ee bixiya jawi lagu tafatiro ku dhawaad ​​nooc kasta oo barnaamij ah. Oo markaad ku darto kordhinta PowerShell , waxaad helaysaa waayo-aragnimo tafatir qoraal ah oo is-dhexgal buuxda leh, xitaa taageerada IntelliSense (code-completing).

Waa kuwan sida loo abuuro faylka qoraalka PowerShell Windows 11/10 iyadoo la adeegsanayo VS Code :

  • U gudub bogga soo dejinta Visual Studio(Head to Visual Studio Download page) .
  • Guji  badhanka Windows  si aad u soo dejiso rakibaha.
  • Laba-guji(Double-click) faylka la soo dejiyay si aad u bilowdo habka rakibida VS Code .
  • Xaqiiji shuruudaha heshiiska.
  • Guji   badhanka Xiga(Next)
  • Guji   badhanka Xiga mar labaad.(Next)
  • Guji  badhanka Xiga(Next)  hal mar oo kale.
  • Xaqiiji(Confirm) hawlo dheeraad ah sida loo baahdo.
  • Guji   badhanka Xiga(Next)
  • Guji   badhanka Ku rakib(Install)
  • Guji   badhanka dhame .(Finish)

Markaad dhammaystirto tillaabooyinka, waxaad sii wadi kartaa inaad ku rakibto kordhinta PowerShell . Waa kan sida:

  • Fur  VS Code .
  • Guji qaybta  Extensions ee dhinaca bidix ama tabo furaha CTRL + SHIFT + X
  • Raadi  PowerShell  oo dooro natiijada ugu sareysa.
  • Guji   badhanka Ku rakib(Install)

Kadib markaad dhamaystirto tillaabooyinka rakibaadda, waxaad bilaabi kartaa qorista qoraallada PowerShell adigoo isticmaalaya (PowerShell)Code-ka Studio(Studio Code) -ga Visual . Waa kan sida:

  • Fur  VS Code .
  • Guji  liiska Faylka(File)  oo dooro  ikhtiyaarka Faylka Cusub(New File)  .
  • Guji  liiska Faylka(File)  oo dooro  Save sida(Save as)  ikhtiyaarka ah.
  • Meesha magaca faylka(File name) ku sheeg magaca faylka leh .ps1  kordhinta - tusaale ahaan,  TWC_script.ps1 .
  • Guji   badhanka Save .

Qor cusub, ama dheji qoraalka aad rabto inaad socodsiiso - tusaale ahaan:

Write-Host "Welcome to TheWindowsClub.com! Your first script executed successfully"

Qoraalka sare wuxuu soo saari doonaa weedha hoose ee shaashadda.

Welcome to TheWindowsClub.com! Your first script executed successfully

Waxaad riixi kartaa badhanka Run  dhinaca sare ee midig (ama riix furaha F5) si aad u socodsiiso qoraalka.

  • Guji  liiska Faylka(File)  .
  • Guji   ikhtiyaarka Save .

Markaad dhamaystirto tillaabooyinka adoo isticmaalaya Visual Studio Code , qoraalku wuxuu diyaar u noqon doonaa inuu shaqeeyo, laakiin wuxuu ku guuldareysan doonaa si caadi ah. Tani waa sababta oo ah goobaha PowerShell ee caadiga ah ayaa had iyo jeer loo dejiyay inay xannibaan fulinta qoraal kasta . (Waxa kaliya ee ka reeban waa haddii aad ku socodsiiso nuxurka qoraalka gudaha Visual Studio Code ama PowerShell ISE .)

Sida loo socodsiiyo faylka qoraalka PowerShell Windows 11/10(PowerShell)

Si aad faylka qoraalka ugu socodsiiso PowerShell , waa inaad beddeshaa siyaasadda fulinta Windows 11/10 .

On Windows 11/10 , PowerShell waxaa ku jira afar siyaasadood oo fulinta, oo ay ku jiraan:

  1. La xaddiday - Waxay(Restricted —)  joojisaa qoraal kasta inuu socdo.
  2. RemoteSigned - Oggolow (RemoteSigned —) qoraallada(Allows) lagu abuuray qalabka, laakiin qoraallada lagu abuuray kombuyuutar kale ma socon doonaan ilaa ay ku jiraan saxiixa daabace la aamini karo mooyee.
  3. AllSigned -  Dhammaan qoraallada waa socon doonaan, laakiin waa haddii daabace la aamini karo uu saxiixo.
  4. Aan xadidnayn - (Unrestricted —) Wuxuu wadaa(Runs) qoraal kasta iyada oo aan wax xaddidaad ah lahayn.

Waa kuwan sida loo socodsiiyo faylka qoraalka PowerShell Windows 11/10:(PowerShell)

  • Riix Windows key + X si aad u furto Menu User Power(open Power User Menu) .
  • Riix A kiiboodhka si aad u bilawdo PowerShell habka maamulka/sare.
  • Gudaha PowerShell console, ku qor amarka hoose oo ku dhufo Gelida(Enter) .
Set-ExecutionPolicy RemoteSigned
  • Nooca  A oo ku dhufo Gelida (haddii ay khuseyso).

Marka xigta, ku qor amarka hoose oo ku dhufo Enter si aad u socodsiiso qoraalka. Hubi(Make) inaad u beddesho meeleeyaha "PATHTOSCRIPT" goobta qoraalkaaga.

& "C:\PATH\TO\SCRIPT\TWC_script.ps1"

Kadib markaad dhamaystirto tillaabooyinka, qoraalka ayaa socon doona, haddii si sax ah loo qoray, waa inaad aragto wax soo saarkiisa iyada oo aan wax dhibaato ah dhicin.

Taasi waa sida loo abuuro loona socodsiiyo faylka qoraalka PowerShell Windows 11/10 !

la xidhiidha(Related) : Sida loo socodsiiyo qoraalada PowerShell maxaliga ah iyada oo aan la saxeexin(How to run local PowerShell Scripts without Signing) .



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