# Arguments not passing through

**URL:** <https://forums.powershell.org/t/arguments-not-passing-through/1072>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/arguments-not-passing-through/1072 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/arguments-not-passing-through/1072/1 "2011-12-31T18:30:00Z")

</div>

by justjon at 2013-02-08 01:24:24

> Hi all,  
>   
> I’m brand new to PowerShell and am having many problems trying to get arguments to pass through succesfully.  
>   
> I’m using PowerGUI to compile the script into an exe.  
>   
> The part of the script that isn’t working is this;  
>   
> `param ( [string]$state, [string]$server )Write-Host State: $state Server: $server`Basically, when running the script it just shows:  
>   
> **State: Server]  
> I’ve tried various different things but simply can’t get it to work.**  
>   
> **Any help would be appreciated.**

by Klaas at 2013-02-08 03:05:48

> So the Write-Host statement works, but both variables are empty.  
> I think we need to see more of your script and the way you call it to find the problem.

by pstosso at 2013-03-28 22:39:08

> try something like this.   
>   
> `function test ( $state, $server){	Write-Host "State: $state Server: $server"}test var1 var2`  
>   
> my output was "State: var1 Server: var2"

by nohandle at 2013-03-29 06:48:17

> ![a user uploaded image]()  
> Seems to work OK for me if this is what you are after.  
>   
> If you’d save that script to c:\temp as test.ps1 you then need to call it (from another script) like this:   
> `c:\temp\test.ps1 -State "ok" -Server "localhost"`

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:02pm UTC](https://forums.powershell.org/t/arguments-not-passing-through/1072/2 "2024-05-16T21:02:39Z")

</div>


