Käyttäjän työkalut

Sivuston työkalut


ohjeet:skriptit

Erot

Tämä näyttää erot valitun ja nykyisen version kesken tästä sivusta.

Linkki vertailunäkymään

Both sides previous revisionEdellinen revisio
Seuraava revisio
Edellinen revisio
ohjeet:skriptit [2012/09/28 13:52] matronkaohjeet:skriptit [2015/09/21 11:46] (nykyinen) – [Luo package ja programsit Configuration Manageriin] matronka
Rivi 213: Rivi 213:
  
   If version = "6.0.350" Then   If version = "6.0.350" Then
-    wScript.Quit(0)+    wScript.Echo("Asennettuna")
   End If   End If
-<\code>+   
 +  wScript.Quit 
 +</code> 
 + 
 +==== Luo package ja programsit Configuration Manageriin ==== 
 +<code powershell> 
 + 
 +#Set the program to be run only on x64 systems. 
 +Function SetOperatingSystemsx64 { 
 +$Program = $Args[0] 
 + 
 +$OSystemsx64 = @(@("6.10.9999.9999","6.10.0000.0"),
 + @("6.20.9999.9999","6.20.0000.0"),
 + @("6.30.9999.9999","6.30.0000.0"),
 + @("5.20.9999.9999","5.20.0000.0"),
 + @("5.20.3790.2","5.20.3790.0"),
 + @("6.00.9999.9999","6.00.0000.1"),
 + @("6.10.9999.9998","6.10.0000.0"),
 + @("6.30.9999.9998","6.30.0000.0"),
 + @("6.20.9999.9998","6.20.0000.0"),
 + @("6.00.9999.9999","6.00.0000.0"),
 + @("5.20.9999.9999","5.20.3790.0"),
 + @("10.00.9999.9999","10.00.0000.0")) 
 + 
 +$OS_Details = @() 
 + 
 +ForEach ($Plat in $OSystemsx64) { 
 +$NewOS = ([wmiclass]"\\configmgr.utu.fi\root\sms\site_TUY:SMS_OS_Details").CreateInstance() 
 +$NewOS.MaxVersion = $Plat[0] 
 +$NewOS.MinVersion = $Plat[1] 
 +$NewOS.Name = "Win NT" 
 +$NewOS.PlatForm = "x64" 
 +$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 = @(@("6.10.9999.9999","6.10.0000.0"),
 + @("6.20.9999.9999","6.20.0000.0"),
 + @("6.30.9999.9999","6.30.0000.0"),
 + @("5.20.9999.9999","5.20.0000.0"),
 + @("5.20.3790.2","5.20.3790.0"),
 + @("6.00.9999.9999","6.00.0000.1"),
 + @("6.00.9999.9999","6.00.0000.0"),
 + @("5.10.9999.9999","5.10.0000.0"),
 + @("10.00.9999.9999","10.00.0000.0")) 
 + 
 + $OS_Details = @() 
 + 
 +ForEach ($Plat in $OSystemsx86) { 
 +$NewOS = ([wmiclass]"\\configmgr.utu.fi\root\sms\site_TUY:SMS_OS_Details").CreateInstance() 
 +$NewOS.MaxVersion = $Plat[0] 
 +$NewOS.MinVersion = $Plat[1] 
 +$NewOS.Name = "Win NT" 
 +$NewOS.PlatForm = "I386" 
 +$NewOS *>$Null 
 + 
 +$OS_Details = $OS_Details + $NewOS 
 +
 + 
 +$Program.Get() 
 +$Program.SupportedOperatingSystems = $OS_Details 
 +$Program.Put() 
 +
 + 
 +Function CreateProgram { 
 +If(!(Get-Module ConfigurationManager)) {Import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager"
 +cd TUY: 
 + 
 +New-CMProgram ` 
 + -PackageName $Args[0].Name ` 
 + -StandardProgramName $Args[1].Name ` 
 + -CommandLine $Args[1].CommandLine ` 
 + -DiskSpaceRequirement $Args[1].DiskSpace ` 
 + -DiskSpaceUnit $Args[1].DiskSpaceUnit ` 
 + -ProgramRunType $Args[1].RunType `  
 + -Duration $Args[1].RunTime ` 
 + -RunMode $Args[1].RunMode ` 
 + -UserInterAction ([System.Convert]::ToBoolean($Args[1].UserInteraction)) *>$Null 
 + 
 +$CMProgram = Get-CMProgram -PackageId $Args[0].PackageId -ProgramName $Args[1].Name 
 + 
 +Switch ($Args[1].Bitness) 
 + {"x64" {$CMProgram.ProgramFlags = $CMProgram.ProgramFlags -bxor ([math]::pow(2,27)); $CMProgram.Put(); SetOperatingSystemsx64 $CMProgram } 
 +  "x86" {$CMProgram.ProgramFlags = $CMProgram.ProgramFlags -bxor ([math]::pow(2,27)); $CMProgram.Put(); SetOperatingSystemsx86 $CMProgram } 
 + } 
 + 
 + 
 +If ($Args[1].RunAnotherProgram.Length -gt 0) {$CMProgram.DependentProgram = $Args[0].PackageId + ";;" +$Args[1].RunAnotherProgram;$CMProgram.Put();$CMProgram.ProgramFlags = $CMProgram.ProgramFlags -bxor ([math]::pow(2,7));$CMProgram.Put()} 
 + 
 +#There is no argument for Comment in New-CMProgram so we have to add the Comment with Set-CMProgram. 
 + 
 +Set-CMProgram ` 
 + -StandardProgram ` 
 + -InputObject $Args[0] ` 
 + -StandardProgramName $Args[1].Name 
 + -Comment $Args[1].Comment *>$Null 
 + 
 + 
 +  cd c: 
 +
 + 
 +#Main 
 +If ($args.Length -eq 0) {Write-Host "No software given!";Exit} 
 + 
 +#Read the package settings from PackageDetails.csv, {Name,Language,Manufacturer,Path,Version,DistributeContent}. All other are strings, DistributeContent is Boolean. 
 +#Add Date to the name to randomize the package name. 
 +$PackageDetails = Import-Csv $args[0] 
 +$Date = Get-Date -Format d 
 +$PackageName = $PackageDetails.Name + ".$Date" 
 +$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 "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager"
 +cd TUY: 
 + 
 +#Create the package. 
 +New-CMPackage ` 
 + -Name $PackageName ` 
 + -Language $Palang ` 
 + -Manufacturer $PaManufacturer ` 
 + -Path $PaPath ` 
 + -Version $PaVersion *>$Null 
 + 
 +#Move the package to the right folder. 
 +$NewCMPackage = Get-CMPackage -Name $PackageName 
 +Move-CMObject -FolderPath "TUY:\Package\Test" -InputObject $NewCMPackage 
 + 
 +#Distribute the content if needed. 
 +If($PackageDetails.DistributeContent = "True") {Start-CMContentDistribution -Package $NewCMPackage -DistributionPointName configmgrdp.utu.fi} 
 + 
 +cd c: 
 + 
 +#Import programs from the Programs.csv, {Name,CommandLine,Comment,DiskSpace,DiskSpaceUnit,RunType,Runtime,UserInteraction,RunMode,Bitness,RunAnotherProgram} and create each program. 
 +$Programs = Import-Csv $args[1] 
 +ForEach ($Program in $Programs) {CreateProgram $NewCMPackage $Program} 
 + 
 +cd TUY: 
 + 
 +#Rename the package. 
 +Set-CMPackage ` 
 + -InputObject $NewCMPackage ` 
 + -NewName $PackageDetails.Name *>$Null 
 + 
 +cd c: 
 + 
 +</code> 
 + 
 + 
 +FirefoxPackageDetails.csv: 
 + 
 +Name,Language,Manufacturer,Path,Version,DistributeContent\\ 
 +"Firefox","EN","Mozilla","\\utu.fi\verkkolevyt\Managed Applications\Mozilla Firefox\Mozilla Firefox 38.2.1 esr","38.2.2 ESR","True" 
 + 
 +FirefoxPrograms.csv: 
 + 
 +Name,CommandLine,Comment,DiskSpace,DiskSpaceUnit,RunType,Runtime,UserInteraction,RunMode,Bitness,RunAnotherProgram\\ 
 +"Install, Uninstall (Machine)","wscript.exe runsoftware.vbs","Use this program to Install or Uninstall the machine part of the application.","80","1","0","30","True","1","x86",""\\ 
 +"Install, Uninstall","wscript.exe profile.vbs","Use this program to Install or Uninstall the application.","80","1","0","30","True","0","x86","Install, Uninstall (Machine)" 
ohjeet/skriptit.1348829520.txt.gz · Viimeksi muutettu: 2014/11/20 15:01 (ulkoinen muokkaus)