title: Using PowerShell in nuget package to edit Global.asax
body: <p>Using a Install.ps1 script with a Nuget Package, I'm attempting to add code to the Global.asax.cs file for customization purposes. With my Install.ps1 script the -replace command is not working. Infact I'm not able to assign any text to the variable $a I'm using with -replace and have it written to the "Global.asax.cs" file. The 3 lines of script involving -replace and the clipboard do work with "Windows PowerShell" outside of nuget. I know that the variable $a is passing along content from the clipboard since commenting out "#$customGlobalAsax.Document.Selection.Copy()" will write whatever happens to be in the clipboard into the Global.asax.cs file. 
  Any Suggestions? Thanks.</p>
  
  <pre><code>param($installPath, $toolsPath, $package, $project)
  
  $customGlobalAsax = $project.ProjectItems | ForEach-Object { $_.ProjectItems } | where { $_.Name -eq "Global.asax.cs" }
  $customGlobalAsax.Open()
  $customGlobalAsax.Document.Activate()
  $customGlobalAsax.Document.Selection.SelectAll() 
  $customGlobalAsax.Document.Selection.Copy()
  
  $a = [System.Windows.Forms.Clipboard]::GetText()  
  $a = $a -replace "using Company.Web.Mvc.ViewBase;","using Company.Web.Mvc.ViewBase;`r`nusing Company.Web.Address;"
  [System.Windows.Forms.Clipboard]::SetText($a)   
  
  $customGlobalAsax.Document.Selection.Delete()
  $customGlobalAsax.Document.Selection.Paste()
  </code></pre>