Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Mit PoweShell Script Werte(Commands) in *.ps1 File schreiben

$
0
0

Moin liebe TechNet Community,

Ich arbeite in letzter Zeit viel mit dem PS AppDeployment Toolkit und das gescrolle für 3 Parameter in dem Script Nervt! 

Also habe Ich mir eine GUI mit Combobox gebaut in der Ich die 8 Wichtigen Stellen im Script Auswählen kann und Anschließend sollen die Werte in die gewünschten Script stellen geschrieben werden. 

Der GUI File ( "Deploy-Application.designer.ps1" ) Wird in einen File ( "Filling_Script.ps1" ) geladen, der die Werte aus der TextBox in das ADT Script ( "Deploy-Application.ps1" ) schreiben soll. 

Doch das Transferieren der Werte scheitert leider :( 

Hier die Datei (Filling_Script.ps1): 

Add-Type -AssemblyName System.Windows.Forms
. (Join-Path $PSScriptRoot 'Deploy-Application.designer.ps1')



$TransferButton.Add_Click( {

        # PRE-INSTALLATION
        if ( $ComboBox1.SelectedItem.ToString() -eq 'PRE-INSTALLATION' ) {
            
            $PreInstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $PreInstallation
        }

        # INSTALLATION
        if ( $ComboBox1.SelectedItem.ToString() -eq 'INSTALLATION' ) {

            $Installation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $Installation
        }

        # ALTERNATIVE-INSTALLATION
        if ( $ComboBox1.SelectedItem.ToString() -eq 'ALTERNATIVE-INSTALLATION' ) {

            $AlternativeInstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $AlternativeInstallation
        }

        # POST-INSTALLATION
        if ( $ComboBox1.SelectedItem.ToString() -eq 'POST-INSTALLATION' ) {

            $PostInstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $PostInstallation
        }

        # PRE-UNINSTALLATION
        if ( $ComboBox1.SelectedItem.ToString() -eq 'PRE-UNINSTALLATION' ) {

            $PreUninstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $PreUninstallation 
        }

        # UNINSTALLATION 
        if ( $ComboBox1.SelectedItem.ToString() -eq 'UNINSTALLATION' ) {

            $Uninstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $Uninstallation
        }

        # ALTERNATIVE-UNINSTALLATION 
        if ( $ComboBox1.SelectedItem.ToString() -eq 'ALTERNATIVE-INSTALLATION' ) {

            $AlternativeUninstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $AlternativeUninstallation
        }

        # POST-UNINSTALLATION
        if ( $ComboBox1.SelectedItem.ToString() -eq 'POST-INSTALLATION' ) {

            $PostUninstallation = $TransferCommandTextBox.Text
            Add-Content $PSScriptRoot'\Deploy-Application.ps1' -Value $PostUninstallation
        }

} )


$ScriptWriter.ShowDialog()

Schon mal danke für eure Unterstützung. 

Grüße OlliverO01


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>