Download .collabdiff file from Code Collaborator - powershell

I want to be able to download patches associated with change lists in Code Collaborator using the Windows command line. These are the files you get in the web GUI if you click on External Diff. They have an extension ".collabdiff", and are in fact zipped archives containing folders for "before" and "after" of each file. I intend to use these to do a three-way merge using Subversion Merge.
My first approach was to use the Code Collaborator command line utility, e.g.
ccollab admin wget externaldiff?reviewid=%2^&changelistid=%3 > %OutputFile%
Unfortunately, it seems that this expects ASCII data only, because a lot of text appears on the screen, and there is a lot of beeping.
My next approach was to use the external link directly. To do this, I have reused a snippet of PowerShell script I found on the web:
::
:: GetCodeCollaboratorChangeList.cmd
::
:: Downloads a review change list from Code Collaborator.
::
:: %1 Code Collaborator Server
:: %2 Review Id
:: %3 Change List Id
::
#ECHO ON
SETLOCAL
SET OutputFile=%~dp0ChangeList_%2_%3.collabdiff
ECHO Creating %OutputFile%.
:: Sadly, the following line expects that ASCII text should be returned, but the URL returns binary text.
:: It beeps a little, and not much text gets redirected.
::ccollab admin wget externaldiff?reviewid=%2^&changelistid=%3 > %OutputFile%
:: So instead, we have to use our own download code.
SET URL="%1/externaldiff?reviewid=%2&changelistid=%3"
SET S=""
SET S="%S:~1,-1% $webclient = New-Object System.Net.WebClient;"
SET S="%S:~1,-1% $webclient.DownloadFile('%URL:~1,-1%','%OutputFile%');"
PowerShell.exe -ExecutionPolicy unrestricted -noprofile -command "& {%S:~1,-1%}"
EXIT /B
Sadly, I get the following error:
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (500) Internal Server Error."
At line:1 char:74
+ & { $webclient = New-Object System.Net.WebClient; $webclient.DownloadFile <<<< ('http://server1/externaldiff?reviewid=8077&changelistid=52915','C:\Documents and Settings\Administrator\Desktop\ChangeList_8077_52915.collabdiff');}
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
When taking the URL and pasting it in the browser (rather than clicking on the link), you get the following page:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
com.smartbear.ccollab.datamodel.DataModelUtils.getDefaultPrevVersionToDiff(DataModelUtils.java:379)
com.smartbear.ccollab.datamodel.DataModelUtils.getDefaultPrevVersionToDiff(DataModelUtils.java:351)
com.smartbear.ccollab.rpc.ExternalDiffConfigServlet.getVersionsToDiff(ExternalDiffConfigServlet.java:373)
com.smartbear.ccollab.rpc.ExternalDiffConfigServlet.service(ExternalDiffConfigServlet.java:140)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.smartbear.ccollab.AuthTicketFilter.doFilter(AuthTicketFilter.java:74)
com.smartbear.ccollab.CollabCleanupFilter.doFilter(CollabCleanupFilter.java:30)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20-patched logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.20-patched
I have tried modifying the code to modify QueryString and BaseAddress properties separately, and called .DownloadFile('/externaldiff, ...) but there was no change in the error.
Are there any suggestions as to how I can download these files?

Try:
ccollab admin wget 'diff?context=10&reviewid=REVIEWID'
Eg:
ccollab admin wget 'diff?context=10&reviewid=12345'

Related

"Invalid namespace" Error when trying to use NetQosPolicy in Powershell

Trying to limit the network bandwidth for a certain application, I came across such a thing as NetQosPolicy. I started trying to create new policies through PowerShell, but kept getting this error:
New-NetQosPolicy : New-NetQosPolicy : Invalid namespace string:1 character:1 + New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -Net ... + + CategoryInfo : MetadataError: (MSFT_NetQosPolicySettingData:ROOT/StandardCi...licySettingData) [New-Net QosPolicy], CimException + FullyQualifiedErrorId : HRESULT 0x8004100e,New-NetQosPolicy
I used this code: New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -NetworkProfile All -ThrottleRateActionBitsPerSecond 1200000
I thought I had made a mistake in the syntax and decided to look at the examples on the Microsoft website (https://learn.microsoft.com/en-us/powershell/module/netqos/new-netqospolicy?view=windowsserver2022-ps), but even their examples cause me the same error.
I haven't found a solution to this problem anywhere, so I'm asking on the forum. I will be grateful to anyone who knows how to solve this problem.
(By the way, I get the same error when I try to use the NetSecurity module (for example, the command: New-NetFirewallRule))
You might have a corrupt wmi repo, read this page but start with this check
Check if the repository is corrupted or not by running following command from command prompt with admin rights: winmgmt /verifyrepository

Add-SBHost : The system cannot find the file specified

I am attempting to add a Host to a newly created Windows Service Bus 1.1 farm but regardless of what I do I eternally get the following error:
VERBOSE: [11/16/2018 2:54:06 PM]: Validating input and configuration parameters.
VERBOSE: [11/16/2018 2:54:06 PM]: Installing auto-generated certificate.
VERBOSE: [11/16/2018 2:54:16 PM]: Granting 'Log on as Service' privilege to the run as account.
VERBOSE: [11/16/2018 2:54:16 PM]: Windows Fabric configuration started.
VERBOSE: [11/16/2018 2:54:28 PM]: Windows Fabric cluster manifest generated.
VERBOSE: [11/16/2018 2:54:28 PM]: Running Windows Fabric deployment.
Add-SBHost : The system cannot find the file specified
At line:1 char:1
+ Add-SBHost -SBFarmDBConnectionString "Data Source=MYHOST;Initial C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-SBHost], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.ServiceBus.Commands.AddSBHost
I had been struggling with configuring the initial deployment of the farm because my organization uses Azure AD. I was following this very helpful Blog post to get through the installation and deployment but the issue I am seeing now isn't covered.
A Google of the issue leads me to this page where they talk about inspecting a DLL. I tried inspecting the Microsoft.ServiceBus.Commands.dll from within the Service Bus installation folder but, I'll be honest, I didn't understand enough to know what I was looking for.
Has anyone else run into this issue before? All suggestions of where I can look to find this are very much appreciated!
Based on my research of what is actually happening in Add-SBHost command, this error may occur when:
Code is trying create new temp file in %userprofile%\AppData\Local\Temp directory for something called "ClusterManifest".
Code is trying to execute FabricDeployer.exe (with created "ClusterManifest" file path as parameter) in directory which is defined in registry path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Service Bus\1.1 for variable WinFabric in folder bin\Fabric\Fabric.Code.1.0. In my case, executable was placed in C:\Program Files\Windows Fabric\bin\Fabric\Fabric.Code.1.0\FabricDeployer.exe
Code is trying to remove temp file (created in 1 point) from %userprofile%\AppData\Local\Temp
After that steps and getting message VERBOSE: [09.08.2019 13:32:26]: Windows Fabric starting. no more file operations should be performed.
What to do?
First of all check if temp file is created in %userprofile%\AppData\Local\Temp directory (sort files by modification date in explorer, run script and wait) - probably file cannot be created because of lack of permissions.
If file is creating properly and has XML inside, then check if Service Fabric is installed and FabricDeployer.exe is present in directory. In my case it wasn't there so i had to remove Windows Fabric and Service Bus. After next installation i made sure that all files were in place.
After these steps script run was successful.
I hope it will help you :)

powershell not expanding variable

I am trying to create a powershell script which installs a load of firewall policies.
I have a file firewalls.txt which has "firewall" "policy" on a single line. I then put that into a variable and try to call it using the "fwm load" command which is an external firewall application binary but the $fwPolstring is not being expanded within the command
$fwPol = Get-Content firewalls.txt
$fwPolString = $fwPol
fwm load "$fwPolString" 2>&1 > InstallLog.txt
I get error in InstallLog.txt
fwm : Missing targets
At C:\fw_estate_install.ps1:3 char:1
+ fwm load "$fwPolString" 2>&1 > InstallLog.txt

How can I fix this "Set-SecureBootUEFI : Incorrect authentication data: 0xC0000022" error?

I used the tutorial and the PowerShell scripts in UefiSecureBootManualTests.zip(EnableSecureBoot.ps1 and append_LostCA_db.ps1) found here to sign an .efi file and enable SecureBoot to see if the system boots(it all worked well).
Now I'm trying to take the winload file from system32, sign it using the same scripts, and then overwrite the keys and see if SecureBoot lets me boot only with the winload I signed.
This time I am using the same scripts, except I modified Set-SecureBootUEFI command in the append_LostCA_db.ps1 deleting -AppendWrite parameter so it can overwrite.
But now I am receiving an error:
Set-SecureBootUEFI : Incorrect authentication data: 0xC0000022
At F:\SecureBoot\AllowNewCertificate\suprascriu_LostCA_db.ps1:13 char:5
+ Set-SecureBootUEFI -Name db -Time 2011-05-21T13:30:00z -ContentFilePath Lost ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (Microsoft.Secur...BootUefiCommand:SetSecureBootUefiCommand) [Set-Secu
reBootUEFI], UnauthorizedAccessException
+ FullyQualifiedErrorId : SetFWVarFailed,Microsoft.SecureBoot.Commands.SetSecureBootUefiCommand
How can I fix this?
I am using a HP desktop with Win8.1 x64
LATER EDIT: It would REALLY help if someone could give me an unsinged winload for 8.1 x64
One of the things that these signatures tell you is that the content has not been modified(that means it is still secure/valid/trustable). So that is the reason why I could not sign a file already signed(the loader used at boot and signed by Microsoft). That's why I was getting the UnauthorizedAccessException.
There is no workaround for this.

Installing an exe with Powershell DSC Package resource gets return code 1619

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.