Here's a basic PowerShell script that creates a GUI for creating an SCCM application:
# Load the Configuration Manager module Import-Module (Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\SMS\Setup" -ErrorAction SilentlyContinue | Get-ItemProperty -Name "SMS_SCI_LocationX86")."SMS_SCI_LocationX86"\bin\configurationmanager.psd1 # Define the form variables $formTitle = "Create SCCM Application" $appNameLabel = "Application Name" $appSourceLabel = "Application Source" $createButtonLabel = "Create" # Create the form $form = New-Object System.Windows.Forms.Form $form.Text = $formTitle $form.Size = New-Object System.Drawing.Size(300,200) $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen # Create the Application Name label and text box $appNameLabelControl = New-Object System.Windows.Forms.Label $appNameLabelControl.Text = $appNameLabel $appNameLabelControl.Location = New-Object System.Drawing.Point(10,20) $appNameTextBox = New-Object System.Windows.Forms.TextBox $appNameTextBox.Location = New-Object System.Drawing.Point(120,20) # Create the Application Source label and text box $appSourceLabelControl = New-Object System.Windows.Forms.Label $appSourceLabelControl.Text = $appSourceLabel $appSourceLabelControl.Location = New-Object System.Drawing.Point(10,60) $appSourceTextBox = New-Object System.Windows.Forms.TextBox $appSourceTextBox.Location = New-Object System.Drawing.Point(120,60) # Create the Create button $createButton = New-Object System.Windows.Forms.Button $createButton.Text = $createButtonLabel $createButton.Location = New-Object System.Drawing.Point(100,100) $createButton.Add_Click({ # Define the variables for the new SCCM application $applicationName = $appNameTextBox.Text $applicationSource = $appSourceTextBox.Text # Create the new SCCM application New-CMDeviceApplication -Name $applicationName -LocalSourcePath $applicationSource # Close the form $form.Close() }) # Add the controls to the form $form.Controls.AddRange(@($appNameLabelControl, $appNameTextBox, $appSourceLabelControl, $appSourceTextBox, $createButton)) # Show the form $form.ShowDialog()
This script creates a GUI that allows you to enter the name and source path of an SCCM application.
When you click the "Create" button, the script creates a new SCCM application
using the New-CMDeviceApplication cmdlet and closes the form.
You can customize this script to fit your specific requirements and to add additional fields and functionality if needed.
No comments:
Post a Comment