Comments (7)
@chrisgelhaus thanks for the report, I will test this out and get a fix put in for it.
from library.
Hey @chrisgelhaus
In your step template, could you try replacing
$isInGroup = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $, $null)}) -contains "$($user.Name)"
with this code snippet instead
$allmembers = @()
$isInGroup = ($members | foreach {
$AdsPath = $_.GetType().InvokeMember("Adspath", "GetProperty", $null, $_, $null)
# Domain members will have an ADSPath like WinNT://<DOMAINNAME>/<USERNAME>
# Local members will have an ADSPath like WinNT://<DOMAINNAME>/<COMPUTERNAME>/<USERNAME>
$a = $AdsPath.split('/', [StringSplitOptions]::RemoveEmptyEntries)
$name = $a[-1]
$domain = $a[-2]
# determine if member is a 'user' or 'group' object
$class = $_.GetType().InvokeMember("Class", "GetProperty", $null, $_, $null)
$allmembers += New-Object PSObject -Property @{
Name = $name;
Domain = $domain;
Class = $class;
ComputerName = $ComputerName;
GroupName = $GroupName;
}
return $allmembers
}) -contains "$($user.Name)"
from library.
I'll try it when I can. I don't know if I mentioned this but my intent is to use this step to add a windows IIS virtual account like "IIS APPPOOL\accountname" to a local security group.
Sent from Outlook Mobile
On Thu, Dec 3, 2015 at 4:15 PM -0800, "Henrik Andersson" [email protected] wrote:
Hey @chrisgelhaus
In your step template, could you try replacing
$isInGroup = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $, $null)}) -contains "$($user.Name)"
with this code snippet instead
$allmembers = @()
$isInGroup = ($members | foreach {
$AdsPath = $_.GetType().InvokeMember("Adspath", "GetProperty", $null, $_, $null)
# Domain members will have an ADSPath like WinNT://<DOMAINNAME>/<USERNAME>
# Local members will have an ADSPath like WinNT://<DOMAINNAME>/<COMPUTERNAME>/<USERNAME>
$a = $AdsPath.split('/', [StringSplitOptions]::RemoveEmptyEntries)
$name = $a[-1]
$domain = $a[-2]
# determine if member is a 'user' or 'group' object
$class = $_.GetType().InvokeMember("Class", "GetProperty", $null, $_, $null)
$allmembers += New-Object PSObject -Property @{
Name = $name;
Domain = $domain;
Class = $class;
ComputerName = $ComputerName;
GroupName = $GroupName;
}
return $allmembers
}) -contains "$($user.Name)"
Reply to this email directly or view it on GitHub:
#255 (comment)
from library.
It was unsuccessful. Below is the error from the step execution. I was able to fix this by using the response to this forum post. It looks like the issue may be directly related to the LENGTH of the username I'm using. Hope this helps.Cheers!
http://stackoverflow.com/questions/18208890/add-iis-apppool-asp-net-v4-0-to-local-windows-group
Windows - Add Users to Local Groups
UserNames: IIS AppPool\OneReallyLongSiteName
GroupNames: DB2USERS
IIS AppPool/OneReallyLongSiteName
IIS AppPool/OneReallyLongSiteName
System.DirectoryServices.DirectoryEntry
Error 11:34:37User IIS AppPool/OneReallyLongSiteName was not foundError 11:34:37At C:\Windows\system32\config\systemprofile\AppData\Local\Tentacle\Temp\63766caError 11:34:373-900e-4de3-a12c-0b506049754f.ps1:131 char:18Error 11:34:37+ throw <<<< "User "+ $userName +" was not found"Error 11:34:37 + CategoryInfo : OperationStopped: (User IIS AppPoo...e was not f Error 11:34:37 ound:String) [], RuntimeExceptionError 11:34:37 + FullyQualifiedErrorId : User IIS AppPool/OneReallyLongSiteName was not f Error 11:34:37 oundInfo 11:34:37ERROR - "WinNT://" not found
Info 11:34:37==============================================
PowerShell exit code: 1
==============================================Fatal 11:34:37PowerShell script returned a non-zero exit code: 1
Tentacle version 2.6.4.951
Date: Thu, 3 Dec 2015 16:15:33 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [Library] Step Template - Windows Add Users to Local Groups (#255)
Hey @chrisgelhaus
In your step template, could you try replacing
$isInGroup = ($members | foreach {$_.GetType().InvokeMember("Name", 'GetProperty',
with this code snippet instead
$allmembers = @()
$isInGroup = ($members | foreach {
$AdsPath = $_.GetType().InvokeMember("Adspath", "GetProperty", $null, $_, $null)
# Domain members will have an ADSPath like WinNT://<DOMAINNAME>/<USERNAME>
# Local members will have an ADSPath like WinNT://<DOMAINNAME>/<COMPUTERNAME>/<USERNAME>
$a = $AdsPath.split('/', [StringSplitOptions]::RemoveEmptyEntries)
$name = $a[-1]
$domain = $a[-2]
# determine if member is a 'user' or 'group' object
$class = $_.GetType().InvokeMember("Class", "GetProperty", $null, $_, $null)
$allmembers += New-Object PSObject -Property @{
Name = $name;
Domain = $domain;
Class = $class;
ComputerName = $ComputerName;
GroupName = $GroupName;
}
return $allmembers
}) -contains "$($user.Name)"
—
Reply to this email directly or view it on GitHub.
from library.
@chrisgelhaus great to hear that you were able to get it working in the end!
Could you send through your step template so that we can update it in the library?
Thanks!
from library.
Hi Henrick,I apologize. I didn't update the library step template with those commands, I created my own step template using those commands. You have a better understanding of the step template than I do, so I didnt want to mess anything up. I can try to integrate them if you like, But I figured you'd be better at it than me!
Cheers!Chris
This is my entire step template:
$group = [ADSI]"WinNT://$Env:ComputerName/$localGroupName,group"$ntAccount = New-Object System.Security.Principal.NTAccount("$userAccount")$strSID = $ntAccount.Translate([System.Security.Principal.SecurityIdentifier])$user = [ADSI]"WinNT://$strSID"$group.Add($user.Path)
Date: Sun, 6 Dec 2015 16:08:05 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [Library] Step Template - Windows Add Users to Local Groups (#255)
@chrisgelhaus great to hear that you were able to get it working in the end!
Could you send through your step template so that we can update it in the library?
Thanks!
—
Reply to this email directly or view it on GitHub.
from library.
Thanks @chrisgelhaus I'll rework the current step template in the Library 👍
from library.
Related Issues (20)
- Question: How to Include Packages HOT 1
- Unable to install Kubernetes - Create Service Account and Target step template HOT 4
- [Feature Request] Annotations on K8s namespace HOT 3
- Chain Deployment step template fails to create a new release of a project HOT 6
- getting commit list into step powershell code. HOT 1
- Add support for TLS 1.2 for Teams - Post a message step template HOT 2
- Windows Scheduled Task step fails if password contains double quote HOT 1
- Create Database Release (Worker Friendly) does not work with vanilla NuGet packages HOT 6
- Azure Logo HOT 1
- Repository - support Libraries of Departmental ALIA HOT 1
- Slack Detailed Notification failed if the release notes includes some special characters like & or | HOT 5
- GCP Secret Manager - Retrieve Secrets - Add option to ignore warning when retrieving latest version of secret HOT 2
- Upcoming major releases of Chocolatey products that may impact functionality on the Chocolatey step templates HOT 7
- Command Timeout parameter has no effect in SQL - Deploy DACPAC using SqlPackage step template HOT 2
- The service cannot accept control messages at this time HOT 2
- Issue with Microsoft Teams - Post a message HOT 6
- Issue with Git - Pull (HTTPS)
- SQL - Deploy DACPAC using SqlPackage - Lost functionality when updating from legacy package HOT 10
- Issue with Run Azure DevOps Build Pipeline HOT 2
- Issue with Run Azure DevOps Build Pipeline
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from library.