title: Run powershell Scripts INSIDE python script
body: <p>I am trying to run a powershell script with in a python script.
  My idea was to do something like:</p>
  
  <pre><code>#pythonscript.py
  
  
  def windowsupdate():
  
      #Somehow call all of this powershell code within the file
  
      Write-Host("Installing module PSWindowsUpdate if not already installed... ")
      Install-Module PSWindowsUpdate
      Write-Host("PSWindowsUpdate is now installed.")
      Write-Host("")
      Write-Host("Getting Windows Updates...")
      Import-Module PSWindowsUpdate
      $updates = Invoke-Command -ScriptBlock {Get-Wulist -verbose}
      $updatenumber = ($updates.kb).count
      if ($null -ne $updates){
          Get-WindowsUpdate -AcceptAll -Install | Out-File C:\PSWindowsUpdate.log
          do {$updatestatus = Get-Content c:\PSWindowsUpdate.log
              "Currently processing the following update:"
              Get-Content c:\PSWindowsUpdate.log | select-object -last 1
              Start-Sleep -Seconds 10
              $ErrorActionPreference = 'SilentlyContinue'
              $installednumber = ([regex]::Matches($updatestatus, "Installed" )).count
              $ErrorActionPreference = ‘Continue’
          }until ( $installednumber -eq $updatenumber)
      }
      Remove-Item -path C:\PSWindowsUpdate.log
  
  
  #call function
  windowsupdate() #opens up a powershell window and goes through the code then when completed close
  
  </code></pre>
  
  <p>If there is any way to do something similar to this without the need of creating a seperate powershell file that would be the best case scenario. If not and it needs to be in its' own file that is okay too, and if it needs to be this way, how would I call the function from within python?</p>
  
  <p>Any help is greatly appreciated!</p>