I am having long script that need to be added to created file, problem is its a script and it contains lots of special chars.
And I am getting a lot of error, I've put script in '' but it did not work as i expected.
Is there an easy way to do it, like taking a text and just adding it to file, somehow with special chars?
powershell.exe Add-Content C:\Testing\Powershell\PageFeature.ps1 - 'Function Press-Button
{
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait('~');
}
Function Resize-Window
{
$pshost = get-host
$pswindow = $pshost.ui.rawui
$newsize = $pswindow.buffersize
$newsize.height = 300
$newsize.width = 128
$pswindow.buffersize = $newsize
$newsize = $pswindow.windowsize
$newsize.height = 5
$newsize.width = 128
$pswindow.windowsize = $newsize
}
Function Run-Tool
{
$ps = new-object System.Diagnostics.Process
$ps.StartInfo.Filename = "C:\Testing\bin.exe"
$ps.StartInfo.RedirectStandardInput = $true
$ps.StartInfo.UseShellExecute = $false
$ps.start()
while ( ! $ps.HasExited ) {
Start-Sleep -s 5
write-host "I will press button now..."
Press-Button
}
Write-Output "Default key was pressed"
Write-Output "exit code: $($ps.ExitCode)"
}
Resize-Window
Run-Tool'
@"`nThext and stuff`n"@. You seem to have a floating hyphen as well. Why are you trying to do this exactly. Where are you doing this from?