When we set breakpoints within a Module we've imported the debugger ignores the breakpoint. Has anybody else seen this behaviour?
This is driving me nuts, we use PowerShell Modules extensively.
The thing that's really weird is I can see the breakpoint if I run get-psbreakpoint
PS H:\Projects\Powershell> get-psbreakpoint | format-list -force
Id : 0
Script : H:\projects\Powershell\Shared\SFTP\SFTP.psm1
Line : 25
Column : 0
Enabled : True
HitCount : 0
Action :
Id : 1
Script : H:\projects\Powershell\Trading\CPPIB\scripts\CppibBorrowReturns.ps1
Line : 12
Column : 0
Enabled : True
HitCount : 1
Action :
EDIT: Seems to work if I delete the psd1 (Manifest file)
Debugging modules can be tough. One way I have been able to do it is load both the module and the code that calls the function you are debugging. In the code that calls a function in the module, place a break point. Then when it its the call to the function in the module, step in to it. Once it steps into the module you should be able to hit F5 again to hit your break point in the module.
Sorry if that is not as clear as it should be, still reeling from day light savings on a Monday.
Related
We want some functionality where we can export the report using the command line so that we can execute that command through some batch file and export reports on a daily schedule time.
Issue:
For this ,we are trying some code snippet from Tally developer "Help --> TDL Sample"(this is complete path of sample code C:\Program Files\TallyPrimeDeveloper\Samples\Whats New\Rel 3.x\Rel 3.0\Programmable Configurations\Export Report Trial Balance.txt).
The following code sample works properly on button click and we are successfully exported the report in our folder
"""[Button: TSPL Smp Export PC]
Key : Ctrl + E
Action : Call : TSPL Smp PC Export Report
Title : "Export Report"
;; Function Definition begins
[Function: TSPL Smp PC Export Report]
Local Formula : SysDate : $$SysInfo:SystemDate
00 : SET : SVExportLocation : "."
10 : SET : SVExportFormat : $$SysName:PDF
20 : SET : SVPrintFileName : "List of Ledgers as onShri_1234 " + $$String:#SysDate + ".PDF"
30 : SET : SVPrintFileName : $$MakeExportName:##SVPrintFileName:##SVExportFormat
40 : EXPORT REPORT : . : TRUE
50 : Msg Box : "TestMsg2" :"We need to download this report through command line" """
But we are facing issue when we are trying to call this same function through command line
Command line is : "C:\Program Files\TallyPrime\tally.exe" /Load:10000 /Action:Call:TSPLSmpPCExportReport .
As per our observations and debugging, the above function gets successfully called through the command line because when I am executing it through the command line,I am getting a "TestMsg2" popup but the file is not getting exported. It seems there is some issue only in file export through the command line, not in function calling through the command line.
I have a solution that works, but without TDL and uses C# or Python
Using C# you can create console app, and you can use that in command line
using Python, you can create script and run from command line
Refer this video for python
I created complex forms application in powersheel and it is running correctly in Powershell ISE and powershell console too, but there is little difference in behaviour:
when I run application by double clicking in windows explorer, powershell console opens, but there is toooo much of "debug" data from creating all form controls(checkboxes, labels, buttons...). It takes too long to start and it looks like this:
TextImageRelation : Overlay UseMnemonic : True UseCompatibleTextRendering : True UseVisualStyleBackColor : True AccessibilityObject : ControlAccessibleObject: Owner = System.Windows.Forms.CheckBox, CheckState: 0 AccessibleDefaultActionDescription : AccessibleDescription : AccessibleName : AccessibleRole : Default AllowDrop : False Anchor : Top, Left AutoScrollOffset : {X=0,Y=0} LayoutEngine : System.Windows.Forms.Layout.DefaultLayout BackgroundImage : BackgroundImageLayout : Tile BindingContext : {} Bottom : 208 Bounds : {X=165,Y=190,Width=96,Height=18} CanFocus : False CanSelect : False Capture : False CausesValidation : True ClientRectangle : {X=0,Y=0,Width=96,Height=18}
This output is not in powershell ISE(there is none) - there application starts immediately.
I was not able to resolve this issue and I would like to remove debug output when run from console, if it is possible - to speed up script start.
Script source code is same as examples on internet, for example like this:
https://learn.microsoft.com/en-us/powershell/scripting/samples/creating-a-custom-input-box?view=powershell-7
I tried yo add | Out-Null to some controls/rows - which i saw in logs, but it did not help.
Also I tried to identify which command is making output by manually adding some controls to console, but none generated that output.
I tried to create ISE profile and load it in script run from console, but it did not help, because created profile file was empty.
If I run new console window like this:
start-process powershell -argumentlist "-noexit", "-noprofile" and run script from that, it works without logs.
But if I run script like this:
start-process powershell -argumentlist "-noexit", "-noprofile", "-command $path"
it outputs logs again.
Any ideas how to do it? What should I check/modify.
Thank you.
solved: problem was a space in script name as I mentioned in comment.
I am writing powershell script for capture OS-disk snapshot for Azure VM but While configuring snapshot I am getting some error.
I am using below command to create snapshot.I am using managed disk.
New-AzSnapshotConfig -OsType Linux -CreateOption copy -SourceUri Microsoft.Azure.Management.Compute.Models.OSDisk -DiskSizeGB 40 -Location 'East US'
Not sure how to do that. If anyone could you please help me to solve this issue.
OUTPUT
WARNING: Breaking changes in the cmdlet 'New-AzSnapshotConfig' :
WARNING: - "The output type 'Microsoft.Azure.Commands.Compute.Automation.Models.PSSnapshot' is changing"
- The following properties in the output type are being deprecated :
'EncryptionSettings'
- The following properties are being added to the output type :
'EncryptionSettingsCollection' 'HyperVGeneration'
WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in
Azure PowerShell.
ResourceGroupName :
ManagedBy :
Sku :
TimeCreated :
OsType : Linux
HyperVGeneration :
CreationData : Microsoft.Azure.Management.Compute.Models.CreationData
DiskSizeGB : 40
EncryptionSettingsCollection :
ProvisioningState :
Id :
Name :
Type :
Location : East US
Tags :
EncryptionSettings :
Thanks
Rohit
Did you go to the link provided in the warning note? It says very clearly:
How do I get rid of the warnings?
To suppress these warning messages, set the environment variable 'SuppressAzurePowerShellBreakingChangeWarnings' to 'true'.
Set-Item Env:\SuppressAzurePowerShellBreakingChangeWarnings "true"
The error message is trying to tell you that the property EncryptionSettings you see in the output you provided will soon be changing from a single property of some type, to a collection property that you would have to iterate over to find all of the settings. They are trying to let you know that if you are capturing the output of New-AzSnapshotConfig to a variable and then calling $variable.EncryptionSettings, your code will work for now, but in the next breaking change release, that call will stop working. Most likely, since that property will no longer exist, the result of that call will simply be a $NULL.
So suppress this warning at your own risk because Microsoft is trying to do you a service here and let you know that if you don't do something about this your code could break. But if you are certain that you never reference property then you have nothing to worry about.
I'm trying to use Powershell DSC's Package resource to install an exe... Perforce's P4V to be specific. Here's my code:
Configuration PerforceMachine
{
Node "SERVERNAME"
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "\\nas\share\p4vinst64.exe"
ProductId = ''
Arguments = "/S /V/qn" # args for silent mode
LogPath = "$env:ProgramData\p4v_install.log"
}
}
}
When running this, this is the error Powershell gives me:
PowerShell provider MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1619 was not expected. Configuration is likely not
correct
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : SERVERNAME
According to documentation, return code 1619 means the MSI package couldn't be opened. However, when I manually log in to the machine and run "\\nas\share\p4vinst64.exe /S /V/qn", the install works flawlessly.
Does anyone know why this is failing? Alternately, can anyone tell me how to troubleshoot this? I pasted all the error information I got from the terminal, my log file (p4v_install.log) is a 0 byte file, and there are no events in the event viewer. I don't know how to troubleshoot it any further!
EDIT: I should note that I also tried using the File resource to copy the file locally, and then install it from there. Sadly, that met with the same result.
Daniel over at the Powershell.org forums was able to figure this out for me.
The P4V InstallShield setup wrapper puts the MSI file into wrong path if you execute as LocalSystem.
I’ve managed to develop a Configuration that works, see below. The key is the /b switch here which puts the MSI file into a defined location. I’ve added ALLUSERS=1 to get the shortcuts visible to all users and REBOOT=ReallySuppress to avoid a sudden restart (which will happen otherwise).
Configuration PerforceMachine
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "C:\My\p4vinst64.exe"
ProductId = ''
Arguments = '/b"C:\Windows\Temp\PerforceClient" /S /V"/qn ALLUSERS=1 REBOOT=ReallySuppress"' # args for silent mode
}
}
Well, what happens here is that the package gets installed (not tested with p4vinst64.exe yet! So, not sure why it says pack cannot be opened as the error) but since you did not specify a ProductID value, the verification at the end of install fails. That is the error you are seeing. The Package resource is no good for installing .exe packages or even MSIs with no ProductID represented as a GUID.
You can use the WindowsProcess resource instead.
I have a matlab function img_process that requires the following parameters : image_name intensity and boundary, so if I run the following on my matlab console :
img_process 'pic1.png' 0.01 1
This will run the function and the image will be processed and I will get a result printed out.
Now I have compiled the script as a windows standalone app named img_process_test. I then try to run it from my command line in windows from the distrib folder like :
img_process_test 'pic1.png' 0.01 1
and it will tell me that error imread , file was not found.
I did try to place the pic1.png in the distrib and src and the img_process_test folders but still it will not work.
Any idea ?
Thank you for looking
I have fixed this. I found a good help here : http://blogs.mathworks.com/loren/2010/12/21/strings-and-numbers-as-arguments/
in case someone stumbles into this and would like to know a workaround.