Hello PowerShell Guru’s,
I am wondering if someone can tell me why this code isn’t working. I’ve reviewed and reviewed it, searched Google up and down with no love.
#Set variables for subversion paths
$ScriptPath = (Split-Path $myinvocation.MyCommand.path -Parent)
[Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Delimon\Delimon.Win32.IO\Delimon.Win32.IO.dll")
Add-Type -AssemblyName Delimon.Win32.IO
Use Delimon.Win32.IO
$scriptDir = "C:\FII"
$z = "C:\Program Files\7-Zip\7z.exe"
$files=gci $scriptDir -r | where {$_.Extension -match "zip"}
foreach ($file in $files) {
$source = $file.FullName
$destination = Delimon.Win32.IO.Directory.Join-Path (Split-Path -parent $file.FullName) $file.BaseName
write-host -fore green $destination
$destination = "-o" + $destination
& ".\$z" x -y $source $destination
}
$files=gci $scriptDir -r | where {$_.Extension -match "prd"}
foreach ($file in $files) {
$source = $file.FullName
$destination = Delimon.Win32.IO.Directory.Join-Path (Split-Path -parent $file.FullName) $file.BaseName
write-host -fore green $destination
$destination = "-o" + $destination
Start-Process 'C:\Program Files\7-Zip\7z.exe x -y $source $destination'
}
Here are the errors I am currently receiving:
GAC Version Location
--- ------- --------
False v4.0.30319 C:\Program Files (x86)\Delimon\Delimon.Win32.IO\Delimon.Win32.IO.dll
Add-Type : Cannot add type. The assembly 'Delimon.Win32.IO' could not be found.
At C:\SVN_Repo\Untitled7.ps1:2 char:1
+ Add-Type -AssemblyName Delimon.Win32.IO
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Delimon.Win32.IO:String) [Add-Type], Exception
+ FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Cannot add type. One or more required assemblies are missing.
At C:\SVN_Repo\Untitled7.ps1:2 char:1
+ Add-Type -AssemblyName Delimon.Win32.IO
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Type], InvalidOperationException
+ FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
Use : The term 'Use' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At C:\SVN_Repo\Untitled7.ps1:3 char:1
+ Use Delimon.Win32.IO
+ ~~~
+ CategoryInfo : ObjectNotFound: (Use:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Delimon.Win32.IO.Directory.Join-Path : The term 'Delimon.Win32.IO.Directory.Join-Path' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\SVN_Repo\Untitled7.ps1:11 char:20
+ $destination = Delimon.Win32.IO.Directory.Join-Path (Split-Path -parent $fil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Delimon.Win32.IO.Directory.Join-Path:String) [], C
ommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
& : The term '.\C:\Program Files\7-Zip\7z.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At C:\SVN_Repo\Untitled7.ps1:14 char:7
+ & ".\$z" x -y $source $destination
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (.\C:\Program Files\7-Zip\7z.exe:String) [], Comman
dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Start-Process : This command cannot be run due to the error: The system cannot find the file
specified.
At C:\SVN_Repo\Untitled7.ps1:23 char:5
+ Start-Process 'C:\Program Files\7-Zip\7z.exe x -y $source $destination'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProces
sCommand