Code Formatting Test

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Joakim Joakim 2 years, 5 months ago.

  • Author
    Posts
  • #16101
    Profile photo of Don Jones
    Don Jones
    Keymaster
    configuration CreatePullServer
    {
        param
        (
            [string[]]$ComputerName = 'localhost'
        )
    
        Import-DSCResource -ModuleName xPSDesiredStateConfiguration
    
        Node $ComputerName
        {
            WindowsFeature DSCServiceFeature
            {
                Ensure = "Present"
                Name   = "DSC-Service"
            }
    
            xDscWebService PSDSCPullServer
            {
                Ensure                  = "Present"
                EndpointName            = "PSDSCPullServer"
                Port                    = 8080
                PhysicalPath            = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
                CertificateThumbPrint   = "AllowUnencryptedTraffic"
                ModulePath              = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
                ConfigurationPath       = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
                State                   = "Started"
                DependsOn               = "[WindowsFeature]DSCServiceFeature"
            }
    
            xDscWebService PSDSCComplianceServer
            {
                Ensure                  = "Present"
                EndpointName            = "PSDSCComplianceServer"
                Port                    = 9080
                PhysicalPath            = "$env:SystemDrive\inetpub\wwwroot\PSDSCComplianceServer"
                CertificateThumbPrint   = "AllowUnencryptedTraffic"
                State                   = "Started"
                IsComplianceServer      = $true
                DependsOn               = ("[WindowsFeature]DSCServiceFeature","[xDSCWebService]PSDSCPullServer")
            }
        }
    }
    
    # Generate MOF
    CreatePullServer -ComputerName dc.company.pri
    
    # push the MOF
    Start-DscConfiguration .\CreatePullServer -Wait
    
    
    $tabs = $psISE.PowerShellTabs
    $curtab = $tabs[$tabs.Count-1]
    $ISEOpt = $psISE.Options
     
    $ISEOpt.OutputPaneBackgroundColor = 'black'
    $ISEOpt.OutputPaneTextBackgroundColor = 'black'
    $ISEOpt.OutputPaneForegroundColor = 'white'
    $TabsMenu = $curtab.AddOnsMenu.Submenus.Add('Tabs',$null,$null)
    if ($curtab -eq $tabs[0]) {
        $curtab.DisplayName = 'NoProfile'
        $newTab = $tabs.Add()
        } else {
        function prompt {
            $psISE.CurrentPowerShellTab.DisplayName = "PoSh # $($tabs.IndexOf($curtab))"
            $(if (test-path variable:/PSDebugContext) { '[DBG]: ' } else { ” }) + 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) + '> '
        }
        $curtab.DisplayName = "PoSh # $($tabs.IndexOf($curtab))"
        $NewTabIndex = $tabs.Count
        $SwitchToMe = [ScriptBlock]::Create("`$tabs.SetSelectedPowerShellTab(`$tabs[$($NewTabIndex-1)])")
        for ($i = 0; $i -lt $tabs.Count - 1; $i++) {
           
            if ($NewTabIndex -le 9) {
                $SwitchTo = [ScriptBlock]::Create("`$tabs.SetSelectedPowerShellTab(`$tabs[$i])")
                $MyMenu = $tabs[$i].AddOnsMenu.Submenus | Where { $_.DisplayName -eq 'Tabs' }
                try {
                    [void] $Mymenu.Submenus.Add($curtab.DisplayName, $SwitchToMe ,"ALT + $NewTabIndex")
                } catch {
                    Write-Debug 'This menu item is already present!'
                }
            } else {
                # That should not happen cause limit is 8
                Write-Host -ForegroundColor Red "Can not add this tab to menu – move to it using CTRL + TAB"
            }
    
  • #16208
    Profile photo of Joakim
    Joakim
    Participant
    Get-Process | select Id, Name
    

You must be logged in to reply to this topic.