I found this link for creating vss Shadow copies under Windows. But the code uses fixed strings for the parameters:
function createVssSnapshot{
[cmdletbinding()]
param(
[string]$targetVolume="C:\",
[string]$accessPath='C:\vssSnapshot',
[bool]$openSnapshotAfter=$true
)
[..]
I'd like to modify it in order to be more flexible:
function [String]createVssSnapshot{
[cmdletbinding()]
param(
[String]$targetVolume,
[String]$accessPath,
[Bool]$openSnapshotAfter
)
[..]
and call it using
$result = createVssSnapshot("C:\", "C:\vssSnapshot", $false)
But I get the following error:
createVssSnapshot : Die Argumenttransformation für den Parameter "targetVolume" kann nicht verarbeitet werden. Der Wert kann nicht in den Typ "System.String" konvertiert werden.
In F:\Powershell_4_Pure\Object_based.ps1:143 Zeichen:28
+ $result = createVssSnapshot("C:\", "C:\vssSnapshot", $false)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [createVssSnapshot], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,createVssSnapshot
Sorry for German error message, but it seems targetVolume isn't of type System.String.
What am I missing here?
For future questions: How can I modify PowerShell ISE to have english error messages?