How to Fix AutoShrink with Powershell?

# Enter the script below in PowerShell ISE, or save it in a ps1 file and execute it from the right location


$a=("localhost","Xu-Acer-PC\I2")

$a | % {
        If ($_ -eq "localhost" )
        {
       
            $Server="Localhost\Default"
            "`r`nProcessing Server: $Server`r`n"
        }
        else
        {
            $Server=$_
            "`r`nProcessing Server: $Server`r`n"
        }
      
        CD sqlserver:\sql\$Server\Databases;
       
        $b=dir;
       
        $b | % {
                $_.Name
                $_.AutoShrink=0;
                $_.Alter()
        }
       
    Trap {
            $err=$_.Exception
            $err.message

            while ($err.InnerException)
            {             
                $err=$err.InnerException
                write-output $err.message
            }
            Continue

       }
  
}