How to affect the way octopus invokes powershell? - octopus-deploy

All is working well, except I wish Powershell was invoked with the -NoProfile flag.
Is it possible?
We use Octopus 3.12.6

The issue 2545 was marked as resolved in 2016 July and it was added in Octopus version 3.3.21.

Related

How to Import-Module in Windows 2008 R2 using Puppet facter?

I'm creating a puppet custom fact using ruby script to output some AD related details. I learned the ServerManager is a prerequisite module as this is not automatically added in the Windows 2008 R2 build yet. I have manually run my powershell commands in one of my 2008 R2 servers and it worked. However, I am getting the following error everytime I run it as a puppet facter.
Appreciate your help on this. Thanks!
Successful Manually run in Windows 2008 R2 server via Powershell
Import-Module ServerManager
Script
if ( $operatingsystemrelease == '2008 R2' )
Facter::Core::Execution.execute(%q[powershell Import-Module ServerManager])
end
Error
error while resolving custom fact "mycustomfact": execution of command "powershell Import-Module ServerManager" failed: command not found.
Source: Facter
Thank you.
The method you have provided worked perfectly fine for me (I tested it with Ruby 2.5.8, 2.6.6, and 2.7.1), so there must be a deeper reasoning for this not working. Nevertheless, I have a solution. In my own personal experience with Ruby and PowerShell I have always used the ` operator which also executes a command and returns the output. For example, you could do:
if ( $operatingsystemrelease == '2008 R2' )
`powershell.exe Import-Module ServerManager`
end
If that still doesn't work, I would turn to your installation of Windows Server, specifically making sure your environment variables haven't been messed up. As unlikely and wild as things may seem sometimes, there are always those moments that can only be explained with "because windows" ;)
Check that the Powershell module exists in the target server - it wasn't available by default until 2008 R2 I believe.
It should be in a folder by the same name at:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules
You also might need to use 32-bit Powershell instead of 64-bit.
Okay. So I've decided to use external facts instead. And it's working fine.
You may look at Puppet's external facts page.
Update
I managed to use ruby puppet custom facter. I removed only %q[]. Here's the script.
if ( $operatingsystemrelease == '2008 R2' )
Facter::Core::Execution.execute('powershell Import-Module ServerManager')
end

Gitlab-Runner service not working in windows

I'm starting with gitlab CI.
I'm using Windows 7. I registred my GitlabRunner, but when I try to install it, I have this issue :
←[0;33mWARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of the upcoming releases←[0;m
←[31;1mFATAL: Failed to start gitlab-runner: The specified service does not exist as an installed service.←[0;m
Can you help me, please ? thnks :)
I found the solution, The service was launched by the Local System user, which does not add the Windows\system32 in the PATH.
I changed the user who launches the service to %username% of the session and it works :)
Sorry if I can't help. This issue seems to be happening in Windows and Linux as well.
I also received the following messages in the terminal:
Setting up gitlab-runner (10.0.0) ...
GitLab Runner: creating gitlab-runner...
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of the upcoming releases
gitlab-runner: Service is not running.
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of the upcoming releases
gitlab-ci-multi-runner: Service is not running.
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of the upcoming releases
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of the upcoming releases

Cannot run Nuget Package Restore from private Team City Nuget Server

Current discussion thread:
http://devnet.jetbrains.com/message/5519081#5519081
Bug Report: http://youtrack.jetbrains.com/issue/TW-37148
Error: Cannot prompt for input in non-interactive mode.
One thing to note is that the credentials prompt is triggering on each package download instead of at the beginning. I think this may be a bug in the way Team City is calling NuGet, but I'm not sure.
I have the "NuGet Feed Credentials" build feature configured, basic auth configured, and I've run the feed in Firefox and got the list of packages to show up on the agent machine (with credentials required).
My build log: https://gist.github.com/tonyeung/517597ca2312dad85f62
The following is a workaround which may help you, although I was of the impression the NuGet Feed Credentials build feature was meant to fix the problem. I was having a similar issue with the internal TeamCity NuGet feed without guest access (called Local in this example).
Initial build step (command line - custom script)
del /F %env.APPDATA%\NuGet\NuGet.Config
%teamcity.agent.tools.dir%\NuGet.CommandLine.DEFAULT.nupkg\tools\nuget.exe sources add -name Local -source %env.NuGetFeed%
%teamcity.agent.tools.dir%\NuGet.CommandLine.DEFAULT.nupkg\tools\nuget.exe sources update -Name Local -User %env.BuildServiceUser% -pass %env.BuildServicePassword%
As I say, it's a workaround, but not too much to maintain if using templates. Hopefully it gets you up and running.
I know this is an old question, but I recently came across this issue in TeamCity 9.1.7.
In my case, the issue was that I had a trailing slash on the Server URL, found in Administration > Global Settings. Removing that slash made the authentication work correctly.
For the TeamCity 8.1.2 (build 29993), I solved this issue by installing the Nuget v. 2.8.0 at the TeamCity Administration panel (I had v.2.8.2). Then I've added "Nuget Install" build step and set up the NuGet Feed Credentials build feature.
Probably, if you'll update the TeamCity it would also fix this issue.
To solve
http://localhost:80/httpAuth/app/nuget/v1/FeedService.svc: The V2 feed at 'http://localhost/httpAuth/app/nuget/v1/FeedService.svc/Packages(Id='***',Version='1.0.0')' returned an unexpected status code '401 Unauthorized'.
issue I have done:
create local administrator account
net user tcbagent password123 /add
net localgroup administrators tcbagent /add
attach "Logon as service" permissions (using Carbon PS helpers)
Grant-CAPrivilege -Identity tcbagent "SeServiceLogonRight"
create account within TeamCity
run cmd using destination environment
runas /user:tcbagent cmd
add nuget source with credentials
nuget sources add -name local -source http://localhost/httpAuth/app/nuget/v1/FeedService.svc -UserName tcbagent -Password password123
localhost of whatever you need
check your teamcity-build.log file to get something like this:
Starting NuGet.exe 3.5.0.1284 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT\tools\NuGet.exe
...
Restoring NuGet package xxxx.
...
Using credentials from config. UserName: tcbagent
TeamCity v9.1.7, NuGet v3.5.0-beta
I've spend 2 days to resolve it because I'm quite new with TeamCity and CI.
Hope it was helpful.
seem like a similar issue to https://nuget.codeplex.com/workitem/4172.
Can you try the workaround at the bottom of the issue description?

VS error when creating new WebAPI project

When I create a new WebAPI project (MVC4) I get the following error.
EntityFramework.5.0.0: Failed to initialize the Powershell host. If your powershell execution policy setting is set to AllSigned, open the package manager console to initialize the host first.
jQuery.1.7.1.1: Failed to initialize the Powershell host. If your powershell execution policy setting is set to AllSigned, open the package manager console to initialize the host first.
After Googling I have found a few answers but nothing that works yet.
Error creating new MVC project - EF and JQuery
This answer seems like it should work for me as my last project was a 7z Command Line app and I might have done something daft with 7zip. But I copy pasted the 7-Zip directory from Program Files to Program Files (86) with no luck.
http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/c934fed4-e44e-4a06-9e3b-eccb9c8aa8d6
There is an answer here that might work (I haven't tried it) but even if it does work I wouldnt want to do this every time I create a new project.
Is anyone able to help me with this one?
I got around a similar error by running PowerShell as administrator with the command Set-ExecutionPolicy Unrestricted, restarting Visual Studio, and opening the Package Manager Console before what I wanted to do.
Make sure you understand the security implications of doing this first.
http://technet.microsoft.com/en-us/library/ee176961.aspx
Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned - Only scripts signed by a trusted publisher can be run.
RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted - No restrictions; all Windows PowerShell scripts can be run.
I encountered this issue recently, after re-install VS and install the latest VS update 2, things go well. This works for me at least.

can't change user.name in Teamcity on server2008

I'm trying to have the build agent run under another account than the build-in SYSTEM account. On our previous windows 2003 box this is no issue; just adding it to the buildAgent.properties and configuring the buildservice to run under the required account works fine.
However, on our server 2008 instalation the new setting is not picked up. Can anyone confirm changing this setting actually works on a server2008? / What else can I try?
Ok, I found the answer on the Teamcity forum here, apparantly it's a known issue and will be fixed in 7.1, but for now there are the following options:
install 7.1 EAP
run the agent using the console
apply a dirty, dirty hack in the registry
Upgrading from 7 to 7.1 resulted into a non-working TC installation so I opted for option 2:
To run the agent.bat we put a batch file in the Buildagent directory containing:
%windir%\system32\runas.exe /savecred /user:domain\user "%windir%\system32\cmd.exe /k D:\Teamcity\buildagent3\bin\agent.bat start"

Categories

Resources