ohjeet:skriptit
Erot
Tämä näyttää erot valitun ja nykyisen version kesken tästä sivusta.
Both sides previous revisionEdellinen revisioSeuraava revisio | Edellinen revisio | ||
ohjeet:skriptit [2014/11/20 15:01] – ulkoinen muokkaus 127.0.0.1 | ohjeet:skriptit [2015/09/21 11:46] (nykyinen) – [Luo package ja programsit Configuration Manageriin] matronka | ||
---|---|---|---|
Rivi 219: | Rivi 219: | ||
</ | </ | ||
+ | ==== Luo package ja programsit Configuration Manageriin ==== | ||
+ | <code powershell> | ||
+ | |||
+ | #Set the program to be run only on x64 systems. | ||
+ | Function SetOperatingSystemsx64 { | ||
+ | $Program = $Args[0] | ||
+ | |||
+ | $OSystemsx64 = @(@(" | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | $OS_Details = @() | ||
+ | |||
+ | ForEach ($Plat in $OSystemsx64) { | ||
+ | $NewOS = ([wmiclass]" | ||
+ | $NewOS.MaxVersion = $Plat[0] | ||
+ | $NewOS.MinVersion = $Plat[1] | ||
+ | $NewOS.Name = "Win NT" | ||
+ | $NewOS.PlatForm = " | ||
+ | $NewOS *>$Null | ||
+ | |||
+ | $OS_Details = $OS_Details + $NewOS | ||
+ | } | ||
+ | |||
+ | $Program.Get() | ||
+ | $Program.SupportedOperatingSystems = $OS_Details | ||
+ | $Program.Put() | ||
+ | } | ||
+ | |||
+ | #Set the program to be run only on x86 systems. | ||
+ | Function SetOperatingSystemsx86 { | ||
+ | $Program = $Args[0] | ||
+ | |||
+ | $OSystemsx86 = @(@(" | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | ForEach ($Plat in $OSystemsx86) { | ||
+ | $NewOS = ([wmiclass]" | ||
+ | $NewOS.MaxVersion = $Plat[0] | ||
+ | $NewOS.MinVersion = $Plat[1] | ||
+ | $NewOS.Name = "Win NT" | ||
+ | $NewOS.PlatForm = " | ||
+ | $NewOS *>$Null | ||
+ | |||
+ | $OS_Details = $OS_Details + $NewOS | ||
+ | } | ||
+ | |||
+ | $Program.Get() | ||
+ | $Program.SupportedOperatingSystems = $OS_Details | ||
+ | $Program.Put() | ||
+ | } | ||
+ | |||
+ | Function CreateProgram { | ||
+ | If(!(Get-Module ConfigurationManager)) {Import-Module " | ||
+ | cd TUY: | ||
+ | |||
+ | New-CMProgram ` | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | $CMProgram = Get-CMProgram -PackageId $Args[0].PackageId -ProgramName $Args[1].Name | ||
+ | |||
+ | Switch ($Args[1].Bitness) | ||
+ | | ||
+ | " | ||
+ | } | ||
+ | |||
+ | |||
+ | If ($Args[1].RunAnotherProgram.Length -gt 0) {$CMProgram.DependentProgram = $Args[0].PackageId + ";;" | ||
+ | |||
+ | #There is no argument for Comment in New-CMProgram so we have to add the Comment with Set-CMProgram. | ||
+ | |||
+ | Set-CMProgram ` | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | cd c: | ||
+ | } | ||
+ | |||
+ | #Main | ||
+ | If ($args.Length -eq 0) {Write-Host "No software given!"; | ||
+ | |||
+ | #Read the package settings from PackageDetails.csv, | ||
+ | #Add Date to the name to randomize the package name. | ||
+ | $PackageDetails = Import-Csv $args[0] | ||
+ | $Date = Get-Date -Format d | ||
+ | $PackageName = $PackageDetails.Name + " | ||
+ | $PaLang = $PackageDetails.Language | ||
+ | $PaManufacturer = $PackageDetails.Manufacturer | ||
+ | $PaPath = $PackageDetails.Path | ||
+ | $PaVersion = $PackageDetails.Version | ||
+ | |||
+ | #Load the module ConfigurationManager and change to the ConfigMgr site. | ||
+ | If(!(Get-Module ConfigurationManager)) {Import-Module " | ||
+ | cd TUY: | ||
+ | |||
+ | #Create the package. | ||
+ | New-CMPackage ` | ||
+ | -Name $PackageName ` | ||
+ | | ||
+ | | ||
+ | -Path $PaPath ` | ||
+ | | ||
+ | |||
+ | #Move the package to the right folder. | ||
+ | $NewCMPackage = Get-CMPackage -Name $PackageName | ||
+ | Move-CMObject -FolderPath " | ||
+ | |||
+ | #Distribute the content if needed. | ||
+ | If($PackageDetails.DistributeContent = " | ||
+ | |||
+ | cd c: | ||
+ | |||
+ | #Import programs from the Programs.csv, | ||
+ | $Programs = Import-Csv $args[1] | ||
+ | ForEach ($Program in $Programs) {CreateProgram $NewCMPackage $Program} | ||
+ | |||
+ | cd TUY: | ||
+ | |||
+ | #Rename the package. | ||
+ | Set-CMPackage ` | ||
+ | | ||
+ | | ||
+ | |||
+ | cd c: | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | FirefoxPackageDetails.csv: | ||
+ | |||
+ | Name, | ||
+ | " | ||
+ | |||
+ | FirefoxPrograms.csv: | ||
+ | |||
+ | Name, | ||
+ | " | ||
+ | " | ||
ohjeet/skriptit.1416488513.txt.gz · Viimeksi muutettu: 2015/09/18 16:48 (ulkoinen muokkaus)