I'm studying team city, and it's just a wonderful thing! However, I have an env.versionReleas to which a value should be assigned in the PowerShell script, but not assigned. The script is quite simple
$sss="afaf"
Write-Host "##teamcity[versionReleas name='env.versionReleas' value='$sss']"
and this variable remains empty. What am I doing wrong?
TeamCity: 2021.1.1 (build 92714)
Spes settings env did not give anything. It seems that Team city does not respond to my message. The answers that are on the site do not help. The value remains empty, just as it was empty
Related
First of all, i'm sorry if this question has been posted before.
I couldn't seem to find and answer we could work with, so here goes..
Backstory:
Every 90 days all password of the NT-accounts will expire.
The office staff gets a notification when they're signing in into Windows 10.
However our iPad users (salesmen and technicians who are on the road) don't get a notification about the expiration.
They use an app which requires a NT-account to sign into our sales system.
Now we've found a Powershell script which would e-mail the user about the expiration of his password, but unfortunately we keep getting the following error:
"The parameter "testing" is declared in parameter-set "__AllParameterSets" multiple times."
As we do not have any Powershell programming skills, we have no idea what going wrong in the script.
Could you guys help us?
The following script is being used (ofcourse edited with our SMTP server and e-mail addresses).
https://gallery.technet.microsoft.com/scriptcenter/Password-Expiry-Email-177c3e27
Much obliged :-)
the code you 1st linked to never, EVER mentions parameter sets. not once. [grin]
the code in your 2nd link mentions it # 106 = __AllParameterSets.
that it IS NOT a parameter set attribute, but is some "other thing". it looks like a call to something in python.
there is no other mention anywhere in your linked code of that __AllParameterSets thing.
so, the fix is to remove it OR to rename it something that does not use a powershell keyword. [grin]
I would like to update the netbootmachinefilepath attribute after clearing it.
Because this attribute can be either non blank or deleted, I need to create it again after the value has been "cleared" because "clearing" it actually deletes it.
How can I recreate this attribute using Powershell?
I was hoping there would be something like
$directoryEntry.Properties.Create("netbootmachinefilepath")
$directoryEntry.CommitChanges()
EDIT Due to software issues on our servers I'm not able to use the ActiveDirectory module.
This should work no matter the attribute has or does not have a value before.
$directoryEntry.Properties["netbootmachinefilepath"].Value = "yourvalue"
$directoryEntry.CommitChanges()
Even $directoryEntry.Properties.Contains("netbootmachinefilepath") is false
$directoryEntry.Properties["netbootmachinefilepath"] will never return null. It return an empty PropertyValueCollection.
Tested the code above and it successfully set the value, even it has no value before.
As the first step in a build configuration I am trying to dynamically change a parameter and use it in the subsequent steps. Reading online, it seems that the way to do this is to call ##teamcity[setParameter. But this doesn't seem to be working. It doesn't even change the value in the same step.
For example, I have created a test parameter and set it's default value to '1'. Inside a powershell script, I tried to change it to 2, as shown below.
But the output remains unchanged as can be seen below
I am currently using TeamCity 8.0.3 (build 27540). What am I doing wrong?
EDIT: I think the problem might be the command you're using to set the parameter. Try:
Write-Host "##teamcity[setParameter name='TestParameter' value='2']"
--
We've experienced the same behavior. The key here is 'subsequent steps.' You must modify the parameter in a separate build step that is run before the step in which you want to use the new parameter.
It's my understanding that all parameters in a build step are evaluated immediately before the execution of that step. The tokens will be replaced with the unmodified values of those parameters. Thus, what actually gets executed by the build agent is:
Write-Host "TestParameter value is 1"
Write-Host "##teamcity[setParameter name='TestParameter' value='2']"
Write-Host "TestParameter value is 1"
We have had a PowerShell script scheduled and executing successfully for the past 3-4 months (In both Test and Prod). The purpose of the script is to update document properties in SharePoint when certain triggers are fired from external systems. Without getting into too much detail, below is the code that has been used to update item properties for a document that has been declared a record:
$recordsmanagement=[Microsoft.Office.RecordsManagement.RecordsRepository.Records]
$recordsmanagement::UndeclareItemAsRecord($item)
$item = $list.GetItemById($item.id)
$item.File.CheckOut()
$item[$sSpFieldName]=$sDbValue
$item.Update()
$item = $list.GetItemById($item.id)
$item.File.CheckIn("")
$recordsmanagement::DeclareItemAsRecord($item)
This code has worked hundreds of times without a problem. For some reason, this code started bombing a week ago on the last line (when re-declaring as a record):
System.Management.Automation.MethodInvocationException: Exception calling "DeclareItemAsRecord" with "1" argument(s): "The file /lib/folder/file.pdf has been modified by SHAREPOINT\system on 10 Oct 2012 00:00:47 -0500."
The other weird part is that this is only happening in Prod. The Test environment seems to execute just fine. I haven't tried a fix for production yet, but I'm pretty sure I can just get the $item object again using GetItemById (after the CheckIn). I'm a little hesitant to do this just yet as I wanted to get some other people's perspective first.
Does anyone have any input on this? Thanks in advance.
I think the best bet is to get the item again after the checkin as you say.
The error message indicates exactly that. You are trying to perform an operation on a SPListItem that has been modified. So pull it again using GetItemById before you declare it as a record.
Why it only happens on some records and on some environment I am not sure. I guess Sharepoint is a bit temperamental.
Thing I would try as well:
Check if there is any workflow doing some work on that item when you check it in
Try to use SystemUpdate() instead of Update() if that suits your requirements
Good luck
I have a problem with some old apps and I need to set an environment variable from AD (hurray)
I'm quite new to PS scripting, so I can use some help.
In my AD I have filled the attribute departmentNumber with information, that part works fine.
Now I need to create a logon script which reads this field from the current user (attribute: departmentNumber, derived from: inetOrgPersonUser) and set this as an environment variable called AFDELING.
I know this can be done using a VB script, but I prefer PS. Can anyone help me with this one?
Thanks in advance for your help,
Peter
Working with environment variables in PowerShell involves the special variable $Env and unfortunately you need to use a .NET method to set environment variables as no cmdlet exists (at least as of v2):
[Environment]::SetEnvironmentVariable("AFDELING", "DeptNo", "User")
The first string parameter is the variable name, the second is the value and the third is basically the persistance level requested for the variable: Machine, User or Process - both machine and user will survive a reboot and future applications will have access to them, though you will need to be running PowerShell with an administrative account to modify the machine-level variables.
Getting the user info should be equally easy. There are a variety of ways that you can access Active Directory, though one of the simplest in your case would be to use the System.DirectoryServices.DirectoryEntry class:
$de = New-Object System.DirectoryServices.DirectoryEntry
$DeptNo = $de.Properties["departmentNumber"]
That should query the current user record from a domain controller, and assign the value from the departmentNumber attribute to the $DeptNo variable. You can then just pop that variable into the second parameter from the first example.