How can I load a dump thru Powerdbg's "New-DbgSession" command? - powershell

I am trying to use the Powerdbg module to analyse a kernel dump. I have managed to successfully install the module. But I am unable to start a new session.
New-DbgSession -dump F:\Downloads\021715-61105-01.dmp
But it opens a blank command prompt titled "CDB.exe" and does nothing. I have Windbg installed on my machine. and the `debuggerroot' variable is rightly pointed to its path. What could I be doing wrong?
The codeplex Powerdbg discussion page isn't active.

i have been intending to try this so i downloaded the latest package and tested it result is as follows see if you can follow through it
i created a bat file which sets the DebuggingTools Environment variable to windows 8.0 debugger installation (xp virtual machine)
in the bat file i invoke powershell with Import-module
when i get a ps command prompt i start a new verbose dbgSession with a dumpfile test.dmp located at c:\
:dir /b
Install_PowerDbg.bat
PowerDbg.psm1
PowerDbgConsole.ps1
PowerDbg_6.10.10.22.zip
runpdbg.bat
:type runpdbg.bat
set DebuggingTools=c:\Program Files\Windows Kits\8.0\Debuggers\x86
c:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -nologo -noexit -comma
nd "Import-Module" .\powerdbg.psm1
:runpdbg.bat
:set DebuggingTools=c:\Program Files\Windows Kits\8.0\Debuggers\x86
:c:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -nologo -noexit -comm
and "Import-Module" .\powerdbg.psm1
WARNING: Some imported command names include unapproved verbs which might make
them less discoverable. Use the Verbose parameter for more detail or type
Get-Verb to see the list of approved verbs.
WARNING: Some imported command names contain one or more of the following
restricted characters: # , ( ) {{ }} [ ] & - / \ $ ^ ; : " ' < > | ? # ` * % +
= ~
PS C:\Documents and Settings\Admin\Desktop\PowerDbg_6.10.10.22> New-DbgSession -
verbose -dump C:\test.dmp
VERBOSE: Using debugging tools from c:\Program Files\Windows
Kits\8.0\Debuggers\x86
VERBOSE: c:\Program Files\Windows Kits\8.0\Debuggers\x86\CDB.exe -z C:\test.dmp
VERBOSE:
Verb :
Arguments : -z C:\test.dmp
CreateNoWindow : False
EnvironmentVariables : {pathext, homepath, symbol_path, clientname...}
RedirectStandardInput : True
RedirectStandardOutput : True
RedirectStandardError : True
StandardErrorEncoding :
StandardOutputEncoding :
UseShellExecute : False
Verbs : {Enable/Disable Digital Signature Icons, open, Open
i
n PPEE (puppy), Open with CFF Explorer...}
UserName :
Password :
Domain :
LoadUserProfile : False
FileName : c:\Program Files\Windows
Kits\8.0\Debuggers\x86\CDB.e
xe
WorkingDirectory : C:\Documents and
Settings\Admin\Desktop\PowerDbg_6.10
.10.22
ErrorDialog : False
ErrorDialogParentHandle : 0
WindowStyle : Normal
VERBOSE: RX (discard)
VERBOSE: TX: .echo PowerDbg connected
VERBOSE: RX: PowerDbg connected
VERBOSE: RX: 0:000> PowerDbg_Complete_184742.640
VERBOSE: RX Complete
VERBOSE: RX (discard) 0:000>
VERBOSE: TX: .printf "%d\n", #$ptrsize
VERBOSE: RX: 4
VERBOSE: RX: 0:000> PowerDbg_Complete_184742.656
VERBOSE: RX Complete
VERBOSE: Connected to 32 bit process/dump
PS C:\Documents and Settings\Admin\Desktop\PowerDbg_6.10.10.22>
this command also seems to start a session correctly (you may need to add debugger path explicitly in $searchpath in powerdbg.psm1 line arount 440 in function Get-DbgToolsLocation()
powershell.exe -nologo -noexit -File PowerDbgConsole.ps1 -verbose -dump c:\test.dmp

Related

PowerShell, only "> $out" catch full error of failed 7Zip extract, why?

I tried all suggestion on how to catch errors of 7Zip as explained in:
powershell - How to capture output in a variable rather than a logfile? - Stack Overflow
Redirecting output to $null in PowerShell, but ensuring the variable remains set - Stack Overflow
and played with try / catch.
Second contains only
Cannot find drive. A drive with the name ' 7-Zip 18.05 (x64) ' does
not exist.
in Error[0]
If I write the console output
7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
Scanning the drive for archives:
1 file, 51273 bytes (51 KiB)
Extracting archive: \\...\850\DAY01
--
7z.exe : ERROR: Data Error : DAY01.RAW
At C:\Users\MyUser\Code\7Zip.ps1:6 char:1
+ & $7ZIP_FullPath x $IN_FullPath -o$OUT_Directory -y
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: Data Error : DAY01.RAW:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Path = \\...\850\DAY01
Type = gzip
Headers Size = 20
Sub items Errors: 1
Archives with Errors: 1
Sub items Errors: 1
in a variable, the variable will contain only
7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
Scanning the drive for archives:
1 file, 51273 bytes (51 KiB)
Extracting archive: \\...\850\DAY01
--
Path = \\...\850\DAY01
Type = gzip
Headers Size = 20
Sub items Errors: 1
Archives with Errors: 1
Sub items Errors: 1
It looks like, that
7z.exe : ERROR: Data Error : DAY01.RAW
At C:\Users\MyUser\Code\7Zip.ps1:6 char:1
+ & $7ZIP_FullPath x $IN_FullPath -o$OUT_Directory -y
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: Data Error : DAY01.RAW:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
is created by PowerShell (what explaiuns 7z.exe : ERROR:..) and can only be captured if I use $out:
& $7ZIP_FullPath x $IN_FullPath -o$OUT_Directory -y > $out
It looks like $out triggers something but what?
7zip is not a PowerShell command so you can’t use the ordinary try{}catch{} with the -ErrorAction Stop
But 7zip has the ability to send out the %errorlevel% values in batch. Which is a better way to find an error
So According to the documentation these are the possible exit codes (%ERRORLEVEL% values):
Code Meaning
==== =======
0 No error
1 Warning (Non fatal error(s)). For example, one or more files were
locked by
some other application, so they were not compressed.
2 Fatal error
7 Command line error
8 Not enough memory for operation
255 User stopped the process
==== =======
In cmd or in a .bat file, there is no problem to run the 7zip command, and on the second line take out the %errorlevel% value, but in powershell you can’t really do that.
If you write the following code in powershell
To Zip:
& cmd.exe /c 'C:\"Program Files"\7-Zip\7z.exe a –mx1 "c:\DestinationFolder\NameOnZipFiles" c:\FolderToZip\*&echo:%errorlevel%'
To Unzip:
& cmd.exe /C 'C:\"Program Files"\7-Zip\7z.exe x "c:\SourceFolder" -o"D:\DestinationFolder" -y&echo:%errorlevel%'
You will notice that the %errorlevel% will always be 0, even if the command fails.
That’s because the %errorlevel% you get is the errorlevel before the command has run.
So to fix that problem you will have to enable the “DelayedExpansion” in cmd with “cmd.exe /v /c
the “%” will also have to be changed to “!” to use the delayed function.
So the correct command needs to be written like this to get the correct errorlevel
To Zip:
& cmd.exe /v /c 'C:\"Program Files"\7-Zip\7z.exe a –mx1 "c:\DestinationFolder\NameOnZipFiles" c:\FolderToZip\*&echo:!errorlevel!'
To Unzip:
& cmd.exe /v /C 'C:\"Program Files"\7-Zip\7z.exe x "c:\SourceFolder" -o"D:\DestinationFolder" -y&echo:!errorlevel!'
More info about the “DelayedExpansion” in cmd https://ss64.com/nt/delayedexpansion.html
Also If you only want to display the errorlevel after command has run, add the following 7zip options “-bso0 -bsp0 -bse0”
To Zip:
& cmd.exe /v /c 'C:\"Program Files"\7-Zip\7z.exe a –mx1 "c:\DestinationFolder\NameOnZipFiles" c:\FolderToZip\* -bso0 -bsp0 -bse0&echo:!errorlevel!'
To Unzip:
& cmd.exe /v /C 'C:\"Program Files"\7-Zip\7z.exe x "c:\SourceFolder" -o"D:\DestinationFolder" –y -bso0 -bsp0 -bse0&echo:!errorlevel!'
But in your case, if your only after having the error text in the same variable just add the 7zip option -bse1
$out=& $7ZIP_FullPath x $IN_FullPath -o$OUT_Directory -y -bse1
#daniel comments got me on the right track but still, I can not explain fully why only this solution is working.
$7ZIPExtractResult= & $7ZIP_FullPath x $IN_FullPath -o$OUT_Directory -y *>&1
Redirects the specified stream to the Success stream.
My guess is, that only that way it can be stored in a variable.
I found help in What does 2>&1 Mean in PowerShell - Stack Overflow and about_Redirection - PowerShell | Microsoft Docs.
In addition, the variable $7ZIPExtractResult is a System.Object[], so I have to do convert an array to a string doing 7ZIPExtractResultAsString = "$7ZIPExtractResult", expecting that is always possible and not throwing a different error.
It is still unknown to me why this error is not caught by
try {
}
catch {
}

Backup-SqlDatabase is not recognized

I have a PowerShell script to backup a database. But today it has stoped working with next error:
Backup-SqlDatabase : The term 'Backup-SqlDatabase' 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.
I didn't change the script. What could be the reason for that?
UPDATE:
Installed SqlServer module. Now I have next:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Temp> import-module sqlserver -erroraction stop -verbose
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\sqlserver\21.0.17224\sqlserver.psd1'.
VERBOSE: Loading 'TypesToProcess' from path 'C:\Program
Files\WindowsPowerShell\Modules\sqlserver\21.0.17224\sqlprovider.types.ps1xml'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program
Files\WindowsPowerShell\Modules\sqlserver\21.0.17224\sqlprovider.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module sqlserver.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\sqlserver\21.0.17224\SqlServer.psm1'.
VERBOSE: Exporting function 'SQLSERVER:'.
VERBOSE: Exporting alias 'Encode-SqlName'.
VERBOSE: Exporting alias 'Decode-SqlName'.
VERBOSE: Importing function 'SQLSERVER:'.
VERBOSE: Importing alias 'Decode-SqlName'.
VERBOSE: Importing alias 'Encode-SqlName'.
PS C:\Temp> Get-Command -Name Backup-SqlDatabase
Get-Command : The term 'Backup-SqlDatabase' 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 line:1 char:1
+ Get-Command -Name Backup-SqlDatabase
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Backup-SqlDatabase:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
UPDATE 2: Uninstalled SqlServer module, directory were removed. After that reinstalled it. Installation log:
PS C:\WINDOWS\system32> Install-Module -Name SqlServer -Repository PSGallery -Verbose
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2/'; IsTrusted
= 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SqlServer'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'SqlServer'.
VERBOSE: Performing the operation "Install-Module" on target "Version '21.0.17224' of module 'SqlServer'".
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'SqlServer' with version '21.0.17224' from the repository
'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='SqlServer'' for ''.
VERBOSE: InstallPackage' - name='SqlServer',
version='21.0.17224',destination='C:\Users\Oleg\AppData\Local\Temp\1981035148'
VERBOSE: DownloadPackage' - name='SqlServer',
version='21.0.17224',destination='C:\Users\Oleg\AppData\Local\Temp\1981035148\SqlServer\SqlServer.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/SqlServer/21.0.17224'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/SqlServer/21.0.17224'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/SqlServer/21.0.17224'.
VERBOSE: Completed downloading 'SqlServer'.
VERBOSE: Hash for package 'SqlServer' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='SqlServer',
version='21.0.17224',destination='C:\Users\Oleg\AppData\Local\Temp\1981035148'
VERBOSE: Catalog file 'SqlServer.cat' is not found in the contents of the module 'SqlServer' being installed.
VERBOSE: Valid authenticode signature found in the file 'SqlServer.psd1' for the module 'SqlServer'.
VERBOSE: Module 'SqlServer' was installed successfully to path 'C:\Program
Files\WindowsPowerShell\Modules\SqlServer\21.0.17224'.
Even after that Import-Module SqlServer -ErrorAction Stop -Verbose hasn't changed and Backup-SqlDatabase is still is not available. What could be the reason?
That function is provided by the sqlps (old & busted) and sqlserver (current) modules. sqlps and older versions of sqlserver were provided by the SQL Server Management Studio installation, but sqlserver is now in the PowerShell Gallery. Assuming you have a current version of PowerShell/Windows Management Framework, you can install-module sqlserver (run in an Administrator PowerShell session) and get the latest version installed globally.
As to what happened to your script:
Possibility #1: You're using a very old version of PowerShell which doesn't auto-load modules and you're not explicitly importing the sqlserver or sqlps module into the session/script where you're calling this function. Solution: upgrade to a current release of PowerShell which does support auto-loading modules and/or explicitly import the proper module into your script/session with import-module.
Possibility #2: Someone uninstalled or moved the module that you're getting that function from, or it's not in your module search path. Solution: Check $PSModulePath and then look in each location for the module. Easiest would be to reinstall it in a global scope.
You need to import the SQL Server PowerShell module to be able to access the cmdlets it contains:
Import-Module SQLPS -ErrorAction Stop
Run this code to see if the function is available to you or not:
Get-Command -Name Backup-SqlDatabase
Here are the results from my machine:
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Backup-SqlDatabase 14.0 SQLPS
I too have the same issue but with Delete-SqlDatabase from SQLPS.
In my case I was trying to call a function Delete-SqlDatabase which I declared and consuming in my code.
The mistake I did is to call the function which was down below.
You see in Powershell in order for a function to be visible, you have to declare it on top. The main function should be the last section hierarchy wise.
Its such a silly thing. I am sure you figured this out within a day.
I am 100% certain this is your issue. I know this thread is too old but it might help other's like me who can potentially save an hours time.

Desktop App to UWP using Desktop App Converter

I have desktop application and want to convert it to an uwp application.
I use desktop app converter with powershell.
I am trying to convert my startup projects exe, but everytime i try execution stops at
Running Installer in Isolated Environment
VERBOSE: No installer valid exit codes specified. Using defaults: 0
VERBOSE: Replace any occurence of in -InstallerArguments
with C:\installer\logs VERBOSE: Running installer command in isolated
environment: VERBOSE: Command Line =
"C:\installer\X.Framework.Main.exe" /passive
part. Is the exe i try to convert is wrong or -InstallerArgument i write? What should i change to end the conversion succesfully?
My PowerShell command:
PS C:\Users\EccE\Desktop\convert> .\DesktopAppConverter.ps1 -Installer
C:\Users\EccE\Desktop\X\X-wpf-framework\bin\Debug\X.Framework.Main.exe
-InstallerArguments "/passive" -Destination C:\Users\EccE\Desktop\X\X-out\ -PackageName "XApp"
-Publisher "CN=X" -Version 0.0.0.1 -MakeAppx -Verbose
Edit:
When i tried to convert project solution i got the following error:
Running Installer in Isolated Environment
VERBOSE: No installer valid exit codes specified. Using defaults: 0
VERBOSE: Replace any occurence of in -InstallerArguments
with C:\installer\logs VERBOSE: Running installer command in isolated
environment: VERBOSE: Command Line =
"C:\installer\X.Framework.sln" /passive VERBOSE: Moving any logs
in
C:\DesktopAppConverter\e931cac0-58a1-46dc-9efd-f5f442a0d814\shared\logs
to C:\DesktopAppConverter\e931cac0-58a1-46dc-9efd-f5f442a0d814\logs
VERBOSE: Cleaning up by removing isolated environment shared folder
'C:\DesktopAppConverter\e931cac0-58a1-46dc-9efd-f5f442a0d814\shared'
VERBOSE: An error occurred. Refer to logs in
C:\DesktopAppConverter\e931cac0-58a1-46dc-9efd-f5f442a0d814\logs
Exception calling "RunIsolatedProcessWithMappedDirectoryAndExport"
with "6" argument(s): " geçerli bir Win32 uygulaması değil. (HRESULT
özel durum döndürdü: 0x800700C1)" At
C:\Users\EccE\Desktop\convert\converter_util\Sequencer.ps1:141 char:9
+ $installerExitCode = [Microsoft.Centennial.Tools.DesktopAppCo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException
VERBOSE: No installer valid exit codes specified
This is due to we need to package our executable program as a installer first, this converter can run your desktop installers through the converter in an unattended (silent) mode and obtain an AppX package that you can install by using the Add-AppxPackage PowerShell cmdlet on your development machine.
See the first paragraph in this document: Desktop App Converter Preview (Project Centennial)
See also the points of Preparing your desktop app for conversion to UWP
Your app installation requires user interaction. Your app installer must be able to run silently, and it must install all of its prerequisites that aren't on by default on a clean OS image.
You can create a MSI package and use converter to generate Appx as you want.

Can't bypass `Restricted` execution policy

I a tool just downloaded that opens a Visual Studio Command prompt from within the IDE, in the root of the current project. My main gripe is that it opens an old style command window, where I would rather have a PowerShell window. According to this post, this simple change should allow this:
cmd.exe /k ""%VS120COMNTOOLS%VsDevCmd.bat" & powershell"
When I this command from outside of VS 2015, it seems to work fine and gives me a PowerShell window. Yet when I try and run it from inside VS, using the utility's menu item, it gives me this error:
Cannot load PSReadline module. Console is running without PSReadline.
. : File
C:\Users\brady\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
cannot be loaded because running scripts is disabled on this system.
For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3
+ . 'C:\Users\brady\Documents\WindowsPowerShell\Microsoft.PowerShell_pr
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess PS C:\Development\vNext\Commerce\src\Commerce.Test> Get-Execution-Policy
PS C:\Development\vNext\Commerce\src\Commerce.Test>
Get-ExecutionPolicy Restricted
My global execution policy is RemoteSigned, but in the same window that show me the error, when I run a Get-ExecutionPolicy, the returned value is Restricted.
I have tried modifying my command to include the PS switch:
cmd /k ""%VS140COMNTOOLS%VsDevCmd.bat" & powershell -ExecutionPolicy Bypass"
But this still gives me exactly the same error.
The output of the command suggested by #PetSerAl in the comments
[Environment]::Is64BitOperatingSystem;[Environment]::Is64BitProcess;Get-Executi‌​onPolicy -List
gives two different results. The first in a normal PS window external to VS:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
And the second in the only PS window I can find inside VS, the Package Manager:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process RemoteSigned
CurrentUser Undefined
LocalMachine Undefined
You can configure an external command and optionally configure a keystroke for it.
I just did this in my VS2015...neat!
Create a cmd file
Create cmd file to call VsDevCmd.bat (Developer Command Prompt for VS2015) and then PowerShell.
dev14powershell.cmd
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
powershell -ExecutionPolicy Bypass
Configure External Tool
Tools -> External Tools
Calls the cmd file above, starts in Solution Dir (configurable)
Run the new External Tool
Result
A new command window started in Solution Directory.
Optional, configure keyboard shortcut
Tools -> Options -> Keyboard
Search for external and remember the number/order of the command you created (4 in my case)
Hit assign and you have:

Build step 'Windows PowerShell' marked build as failure, why?

Below are three PowerShell Commands run in Jenkins and the build result. Why it fails? Which command could be failing? I've read this post: How/When does Execute Shell mark a build as failure in Jenkins?, but couldn't figure out. I am not familiar with MS stuffs.
Command 1:
& "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com" "$env:WORKSPACE\ETL\OnePnL.sln" /Build
Command2:
###########################
# Deploy SSIS package #
###########################
$csource ="$env:WORKSPACE\ETL\Project Type 0\bin\DEFAULT\OnePnL.ispac"
$cserver = "SSASDBDEV01"
$cdest = "/SSISDB/OnePnL/OnePnL"
echo $env:GIT_BRANCH
if ($env:GIT_BRANCH -like '*master*')
{
# Call IS Deployment Wizard
echo "Deploying SSIS package to $cdest on $cserver"
# "C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\ISDeploymentWizard.exe" "/Silent /SourcePath:""$csource"" #/DestinationPath:""$cdest"" /DestinationServer:""$cserver""" -Wait
Start-Process "C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\ISDeploymentWizard.exe" "/Silent /SourcePath:""$csource"" /DestinationPath:""$cdest"" /DestinationServer:""$cserver""" -Wait
}
Command 3:
#####################
# Copy Files to O: drive #
#####################
#Make build directory
#$outputparentdir = "\\orion\Shared\AppUpload\ApplicationPackage\OnePnL Cube\SSIS Jenkins Builds"
$outputparentdir = "\\inv\Shared\Transfer - Deleted Weekly\Jenkins\BI\OnePnL\SSIS Jenkins builds"
$outputdir = "$outputparentdir\${env:GIT_BRANCH}\Build ${env:BUILD_NUMBER}"
echo "Branch"
echo ${env:GIT_BRANCH}
echo "Output directory"
echo $outputdir
if (!(Test-Path "$outputparentdir"))
{
mkdir $outputparentdir
}
mkdir $outputdir
ROBOCOPY "$env:WORKSPACE\ETL\Project Type 0\bin\DEFAULT" "$outputdir" /E /v
echo "Done Copy"
Build result:
[OnePnL SSIS] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\SVC_TE~1\AppData\Local\Temp\hudson3790190217372968147.ps1'"
Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.50727.1.
Copyright (C) Microsoft Corp. All rights reserved.
------ Build started: Project: OnePnL, Configuration: DEFAULT ------
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
[OnePnL SSIS] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\SVC_TE~1\AppData\Local\Temp\hudson2769520726749517170.ps1'"
origin/release
[OnePnL SSIS] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\SVC_TE~1\AppData\Local\Temp\hudson7860003244522954499.ps1'"
Branch
origin/release
Output directory
\\inv\Shared\Transfer - Deleted Weekly\Jenkins\BI\OnePnL\SSIS Jenkins builds\origin/release\Build 74
Directory: \\inv\Shared\Transfer - Deleted Weekly\Jenkins\BI\OnePnL\SSIS
Jenkins builds\origin\release
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10/26/2015 4:29 PM Build 74
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Monday, October 26, 2015 4:29:01 PM
Source : D:\te_jenprodslave_1\workspace\Trade_Efficiencies\BI\OnePnL SSIS\ETL\Project Type 0\bin\DEFAULT\
Dest : \\inv\Shared\Transfer - Deleted Weekly\Jenkins\BI\OnePnL\SSIS Jenkins builds\origin\release\Build 74\
Files : *.*
Options : *.* /V /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
1 D:\te_jenprodslave_1\workspace\Trade_Efficiencies\BI\OnePnL SSIS\ETL\Project Type 0\bin\DEFAULT\
New File 516475 OnePnL.ispac
0%
25%
50%
76%
100%
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 0 0 0 0
Files : 1 1 0 0 0 0
Bytes : 504.3 k 504.3 k 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Speed : 43039583 Bytes/sec.
Speed : 2462.744 MegaBytes/min.
Ended : Monday, October 26, 2015 4:29:01 PM
Done Copy
Build step 'Windows PowerShell' marked build as failure
The answer is sort of in the post you linked.
the exit code of last command of the Jenkin's Execute Shell build step is what determines the success/failure of the Build Step
I get that you understand that much, but what makes it come into play is the return code for robocopy which was you last command. While the link is for server 2008 I won't be surprised if they are OS common.
Value Description
0 No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped.
1 All files were copied successfully.
If all the files were copied successfully then the return code is 1. Anything other than 0 is reported as a failure by the build step as we have read in the linked question.
I think what you need to do is check the return code of robocopy and change it.
To check it you need to look at a PowerShell automatic variable $?
$?
Contains the execution status of the last operation. It contains
TRUE if the last operation succeeded and FALSE if it failed.
So the last couple of lines could be...
ROBOCOPY "$env:WORKSPACE\ETL\Project Type 0\bin\DEFAULT" "$outputdir" /E /v
If($?){exit 0}
What this should do is take any non zero result from robocopy and force the script to return true. Again, be aware that this would return OK for all return codes. If this is not desirable then you could easily build some logic for certain codes.
I cannot really test this code as I do not have your environment but in theory it should work or at least get you started on where you need to be.