PoshCode Logo PowerShell Code Repository

Multiple strings params by alanrenouf 26 months ago
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1512"></script>download | new post

Multiple string parameters

  1. # For example I have this function
  2.  
  3. function copySourceDestination {
  4.         Param (
  5.                 [string]$sourceFile,
  6.                 [string]$destinationPath
  7.         )
  8.  
  9. # Strangely enough $sourceFile will contain both the values of $sourceFile and $destinationPath
  10. # in this case $destinationPath will be empty and $sourceFile will show up as: "C:\bla.txt \\server\share\path"
  11.  
  12.         Copy-Item -Path:$sourceFile -Destination:$destinationPath -Force
  13. }
  14.  
  15.  
  16. # Calling the function
  17. copySourceDestination "C:\bla.txt" "\\server\share\path"

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me