
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2015 06:11 AM
Add users to AD groups based on partial name
call with .\scriptname.ps1 -smartname {computer}
List Computers AD Memberships
call with .\scriptname.ps1 -smartname {computer}
SCCM Remote Control
call with .\scriptname.ps1 -smartname {computer}
call with .\scriptname.ps1 -smartname {computer}
param (
[string]$smartname,
[Int32]$Seconds = 20,
[string]$Message = "waiting for 20 seconds to synchronise bits and pieces..please wait"
)
Import-Module ActiveDirectory
Function AddComputerToGroup{
$adgrp = Read-Host 'What is the AD group name? (Partial or full name)'
$adgrp = "*" + $adgrp + "*"
$adgrp2 = (Get-ADGroup -Filter {name -like $adgrp} | select Name,DistinguishedName,GroupCategory,GroupScope | Out-GridView -OutputMode multiple -Title 'Please select AD group name:').name
if ($adgrp2 -like $null) {
Write-Host "Please enter the AD group name:"
AddComputerToGroup
} elseif ($adgrp2 -ne $null) {
foreach ($adgrp3 in $adgrp2) {
Add-ADGroupMember -Identity "$adgrp3" -Members "$smartname$"
}
}
}
AddComputerToGroup
Write-Host "Computer is being added to groups, please wait" -foregroundcolor "red"
Function Start-Countdown{
ForEach ($Count in (1..$Seconds))
{ Write-Progress -Id 1 -Activity $Message -Status "Waiting for $Seconds seconds, $($Seconds - $Count) left" -PercentComplete (($Count / $Seconds) * 100)
Start-Sleep -Seconds 1
}
Write-Progress -Id 1 -Activity $Message -Status "Completed" -PercentComplete 100 -Completed
}
Start-Countdown -Seconds 10 -Message "Adding to Group..."
Write-Host "Computer $smartname now has the following AD Group Memberships" -foregroundcolor "green"
(Get-ADPrincipalGroupMembership (Get-ADComputer "$smartname").distinguishedname | select name).name
Write-Host "Press any key to close ..." -foregroundcolor "green"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
List Computers AD Memberships
call with .\scriptname.ps1 -smartname {computer}
param (
[string]$smartname
)
Import-Module ActiveDirectory
Write-Host "Computer has the following AD Group Memberships" -foregroundcolor "green"
(Get-ADPrincipalGroupMembership (Get-ADComputer "$smartname").distinguishedname | select name).name
Write-Host "Press any key to close ..." -foregroundcolor "green"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
SCCM Remote Control
call with .\scriptname.ps1 -smartname {computer}
param (
[string]$smartname
)
C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe 1 $smartname
Labels:
- Labels:
-
Custom Actions
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2015 05:25 PM
To avoid that "issue", I call PS scripts like:
powershell -noprofile -ExecutionPolicy bypass -command {actionpath}script.ps1 {assetname}
powershell -noprofile -ExecutionPolicy bypass -command {actionpath}script.ps1 {assetname}

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2015 10:04 PM
Yup, Did that ...working Thx

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 02:04 AM
set-executionpolicy bypass in command line

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 12:31 AM
Can't seem to get it to work fully. When enacting the action the Powershell window flashed briefly then goes away.
The script runs when I use a defined "smartname" within the PS window by itself
we call it using
{actionpath}\example.ps1 -smartname {computer}
*Update: Determined that trying to run script had PowerShell execution policy (run) disabled on local client PC's
The script runs when I use a defined "smartname" within the PS window by itself
we call it using
{actionpath}\example.ps1 -smartname {computer}
*Update: Determined that trying to run script had PowerShell execution policy (run) disabled on local client PC's
