Welcome Forums General PowerShell Q&A FormatStartData

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #68488

    Points: 0
    Rank: Member

    I have the following code which in this script is just copying some files over, gathering some variables and re-naming a computer. The script would only work in ISE so I set it to -STA but I am now getting the following error also.

    set-executionpolicy Bypass -Force
    New-Item -Path C:\Temp\ -ItemType directory
    Copy-Item "\\folder\Onboarding" -Destination "C:\Temp\" -Recurse
    $credential = Get-Credential -Credential "domain.local\"
    $credential.Password | ConvertFrom-SecureString | Set-Content c:\temp\onboarding\cred.txt
    $credential.Username | Set-Content c:\temp\onboarding\user.txt
    #Gather Info
    $localname = Read-Host "Please Enter Local Admin User Name: "
    $localpw = Read-Host "Please Enter Local Admin Password: "
    $floorou = Read-Host 'What floor will the user be in:'
    $Username = Read-Host 'Employee Username'
    $Domainpw = Read-Host 'Employee Password'
    $name = Read-Host "Please Enter ComputerName: "
    $obj = new-object psobject -Property @{
                       LocalName = $localname
                       LocalPW = $localpw
                       Floor  = $floorou
                       User  = $Username
                       DomainPW = $Domainpw
                       ComputerName = $name
            if ($obj.PercentFree -lt 10) {
                $obj | Format-Table LocalName,LocalPW,Floor,User,DomainPW,ComputerName
    $obj | Export-csv "C:\Temp\Onboarding\variables.csv" -notype
    # rename the computer
    $Computer = Get-WmiObject Win32_ComputerSystem
    echo "Renaming Computer...."
    Write-Host "Rebooting Computer..." -foregroundcolor "magenta"
    #Set Auto Login
    New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoAdminLogon -Value 1
    New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultUserName -Value $localname
    New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -Value $localpw
    Copy-Item "C:\Temp\Onboarding\RunScripts\Run1.bat" -Destination "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\"
    shutdown /f /r
    The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-table" command which is conflicting with the default formatting.
        + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
        + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
  • #68490

    Points: 42
    Rank: Member

    try changing

    if ($obj.PercentFree -lt 10) {
                $obj | Format-Table LocalName,LocalPW,Floor,User,DomainPW,ComputerName


    if ($obj.PercentFree -lt 10) {
                $obj | select LocalName,LocalPW,Floor,User,DomainPW,ComputerName

    the problem is the export-csv conflicting with the FT command, could possibly replace the 'export-csv' with 'out-file' but may screw formatting

  • #68593

    Points: 0
    Rank: Member


The topic ‘FormatStartData’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort