• /r/powershell
  • Make your very own For Loop!

    Lets start by creating our little for loop function. function fakeForLoop { [cmdletbinding()] Param( [parameter(ValueFromPipeline)] $InputObject, [parameter(Position=0)] [scriptblock] $ScriptBlock ) Process { . $ScriptBlock } } Now that we have our for loop function created. Lets give it a test. $a = “a”,”b”,”c” $b = {$_} $a | fakeForLoop $b This will return the following. […]

  • /r/powershell
  • Whats wrong with my workflow?

    https://pastebin.com/fTYxyT86 getting this error…. Microsoft.PowerShell.UtilityWrite-Error : Cannot process command because of one or more missing mandatory parameters: ComputerName. At test:16 char:16 + + CategoryInfo : NotSpecified: (:) [Write-Error], ParameterBindingException + FullyQualifiedErrorId : System.Management.Automation.ParameterBindingException,Microsoft.PowerShell.Commands.WriteErrorCommand + PSComputerName : [localhost] I cant use -Computername in a workflow so i used the -PSComputername as that error suggested. Now the […]

  • /r/powershell
  • Background jobs and COM Objects

    Trying to create a table in word and would like to speed up the process a bit, without jobs this works fine but it’s just slow. When I run this script everything works fine except when the script gets to $Table.Cell($x,<column>).Range.Text = <string> It gives the error You cannot call a method on a null-valued […]