Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

Embedding code from Visual Studio Code indenting issue when replying to thread, not when creating?

To Whom it may concerns,

I notice that when I copy paste a script into the thread, recently it does HTML formatting and breaks all of the indentings. See the below for example.

$ListOfServers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "DC=Domain,DC=com"
# If you want in in a text files containing server list or names    
#$ListOfServers = Get-Content "c:\temp\serv.txt"

Foreach ($Server in $ListOfServers) {
    Invoke-Command -ComputerName $Server -ScriptBlock {
        # Get Certificate list and assign to a variable
        $Certs = Get-ChildItem "Cert:\LocalMachine\My" -Recurse

        #To get a list of all cert storage locations.
        #(Get-ChildItem -Path "Cert:" -Recurse | Where-Object {($_).GetType().Name -eq 'X509Store'}).Name        

        # Loop through each object in $Certs
        Foreach ($Cert in $Certs) {
            # If The objects property "NotAfter" is older than the current time, delete
            If ($Cert.NotAfter -lt (Get-Date)) {
                $Cert | Remove-Item -WhatIf # Remove the -WhatIf to make it run for real.
            }
        }
    }
}

Open in new window


Can anyone please suggest if this is a known issue in the new EE website or this is an issue in the Visual Studio code?
Avatar of Albert Widjaja
Albert Widjaja
Flag of Australia image

ASKER

This is when I reply from VS code with the same clipboard content:


Code below is embedded with the proper [code][/code] tags:


$ListOfServers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "DC=Domain,DC=com"
# If you want in in a text files containing server list or names    
#$ListOfServers = Get-Content "c:\temp\serv.txt"
Foreach ($Server in $ListOfServers) {
    Invoke-Command -ComputerName $Server -ScriptBlock {
        # Get Certificate list and assign to a variable
        $Certs = Get-ChildItem "Cert:\LocalMachine\My" -Recurse
        #To get a list of all cert storage locations.
        #(Get-ChildItem -Path "Cert:" -Recurse | Where-Object {($_).GetType().Name -eq 'X509Store'}).Name        
        # Loop through each object in $Certs
        Foreach ($Cert in $Certs) {
            # If The objects property "NotAfter" is older than the current time, delete
            If ($Cert.NotAfter -lt (Get-Date)) {
                $Cert | Remove-Item -WhatIf # Remove the -WhatIf to make it run for real.
            }
        }
    }
}


ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Test with Beta:


$ListOfServers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "DC=Domain,DC=com" # If you want in in a text files containing server list or names     #$ListOfServers = Get-Content "c:\temp\serv.txt"  Foreach ($Server in $ListOfServers) {     Invoke-Command -ComputerName $Server -ScriptBlock {         # Get Certificate list and assign to a variable         $Certs = Get-ChildItem "Cert:\LocalMachine\My" -Recurse          #To get a list of all cert storage locations.         #(Get-ChildItem -Path "Cert:" -Recurse | Where-Object {($_).GetType().Name -eq 'X509Store'}).Name                  # Loop through each object in $Certs         Foreach ($Cert in $Certs) {             # If The objects property "NotAfter" is older than the current time, delete             If ($Cert.NotAfter -lt (Get-Date)) {                 $Cert | Remove-Item -WhatIf # Remove the -WhatIf to make it run for real.             }         }     } } 

Open in new window

I think the text from code is copied properly (as I can saw it in Notepad+ displayed nicely) but somehow the new Beta version of Code doesn't work so well at this moment (I also facing some indent and alignment issues by using the Beta's Code feature)

Yes, it seems this is server-side issue, not my browser (Client side issue).

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$ListOfServers = Get-ADComputer -Filter { Enabled -eq $True -and OperatingSystem -like "*Server*" } -SearchBase "DC=Domain,DC=com"
# If you want in in a text files containing server list or names    
#$ListOfServers = Get-Content "c:\temp\serv.txt"
Foreach ($Server in $ListOfServers) {
    Invoke-Command -ComputerName $Server -ScriptBlock {
        # Get Certificate list and assign to a variable
        $Certs = Get-ChildItem "Cert:\LocalMachine\My" -Recurse
        #To get a list of all cert storage locations.
        #(Get-ChildItem -Path "Cert:" -Recurse | Where-Object {($_).GetType().Name -eq 'X509Store'}).Name        
        # Loop through each object in $Certs
        Foreach ($Cert in $Certs) {
            # If The objects property "NotAfter" is older than the current time, delete
            If ($Cert.NotAfter -lt (Get-Date)) {
                $Cert | Remove-Item -WhatIf # Remove the -WhatIf to make it run for real.
            }
        }
    }
}



There was no "clean" pop up?

thanks!
it is definitely a bug in the beta version.