Can somebody help me with this.I have code where I need to use GetType and FullName for $file variable.For some reason it does not recognise this functions.
param (
[string]$name
)
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Zip {
param([string]$folderInclude, [string]$outZip)
[System.IO.Compression.CompressionLevel]$compression = “Optimal”
$ziparchive = [System.IO.Compression.ZipFile]::Open( $outZip, “Update”)
$realtiveTempFolder = (Resolve-Path $tempFolder -Relative).TrimStart(".")
foreach($file in (Get-ChildItem $folderInclude -Recurse)){
if($file.GetType().ToString() -ne “System.IO.DirectoryInfo”){
$relpath = “”
if($file.FullName){
$relpath = (Resolve-Path $file.FileName -Relative)
}
if(!$relpath){
$relpath = $file.Name
}else{
$relpath = $relpath.Replace($realtiveTempFolder,"")
$relpath = $relpath.TrimStart(".\").TrimStart("\\");
}
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($ziparchive,$file.FullName,$relpath,$compression) || Out-Null
}
}
}
$Directory = Split-Path -Path $name -Parent
$tempFolder = $Directory + “\Populate-Word-DOCX”
Zip $tempFolder $name