Total_Nutter
asked on
Powershell file directoy question
I have a file in the following location
c:\data\users\sales\reps\
Please could somebody help me with a powershell script that will return only the following:
\sales\reps\
and if possible
c:\..\sales\reps\
Many thanks
c:\data\users\sales\reps\
Please could somebody help me with a powershell script that will return only the following:
\sales\reps\
and if possible
c:\..\sales\reps\
Many thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Simple, but works - many thanks
Does this achieve what you require?
function Get-PartPath
{
Param
(
[String]$FullPath,
[string]$MaskPath,
[string]$Prefix = ""
)
return ($Prefix + $fullPath.Substring($maskP
$path
}
Get-PartPath -FullPath "c:\data\users\sales\reps\
If you always use the same value for the mask you could make it a default value:
[string]$MaskPath = "c:\data\users",