Import-Module -Force "E:\Skriptentwickung\released-and-published\Modules\Write-LogFile.psm1" Import-Module -Force "E:\Skriptentwickung\released-and-published\Modules\Test-FileState-withLogging.psm1" Import-Module -Force "E:\Skriptentwickung\development\Modules\Test-ItemVersion-withLogging.psm1" $Error.Clear() cls test-ItemVersion-withLogging -DestinationFile test1.txt -Destinationpath E:\ exit Function Rename-Item-withLogging { Param ( [Parameter(Mandatory=$True,HelpMessage='Give the Full Path, where the Item(s) located.')] [ValidateNotNullOrEmpty()] [String]$Path, [Parameter(Mandatory=$True,HelpMessage='Give the new Name, you want to set.')] [ValidateNotNullOrEmpty()] [String]$NewName ) #end param ###modul loaded?? Write-Host "Path:" Write-Host $Path Try { $Item = Get-Item -Path $Path -ErrorAction Stop } #end try Catch { Write-Host $Error } #end catch $FileState = Test-FileState-withLogging -SourceFile $Item -Action writetest IF ($FileState -eq "writeable") { Write-Host "SourceFile seems to be writeable!" Try { Rename-Item -Path $Item -NewName $NewName -ErrorAction Stop } #end try Catch { Write-Host "Error" } #end catch } #end if return $item } #end function $item = rename-Item-withLogging -path "e:\test.txt" -newname test1.txt