05/06/2021

Powershell repository oluşturmak

İstersek kendi repositorymizi oluşturabiliriz ve orada paketler yayınlayabiliriz.

Powershell bunun için hazır geliyor.

Önce bir script hazırlayacağız ve adı script ile aynı olan bir klasöre koyacağız daha sonra onu module olarak kaydedeceğiz.
* yani uzantısını .ps1 den .psm1 olarak değiştireceğiz.

Daha sonra bir modül manifestosu oluşturmamız lazım

New-ModuleManifest -Path "C:\users\can\scripts\Cantools\Cantools.psd1" -Author "Can" -desciption "Tools for work" -version "1.0"

Böylece manifesto dosyasını otomatk oluşturacak geri kalan verileri kendi hazırlayacak ve modüle ilişkin export edilen fonksiyonlarıda hepsi olarak ayarlayacak.

Artık publish edebiliriz.

C:> Publish-module -path "C:\users\can\scripts\Cantools" -repository Cantools

Publish ettiğimiz lokasyon bir ağ lokasyonuda olabilir. Bu durumda ağda b klasöre erişebilen tüm kullanıcılar içinde ki modülleri kullanabilirler.

C:> Register-PSRepository -name Cantools -InstallationPolicy trsuted -PublishLocation "C:\users\can\scripts\Cantools" -SourceLocation "C:\users\can\scripts\Cantools"

Artık bundan sonra kullanıcılar install-module ile direk kurabilirler. Mevcut repoları görmek için

PS C:\Users\can> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2

Leave a Reply