Help with a Module, a script, and a shortcut

Hi everyone,

I have created a little function to delete the TelephoneNumber and ipPhone field from an ADuser and thus rip them out of our Cisco UC system. Worrying that running the function may be too difficult for the helpdesk I was asked to make it a short script that asks plain english questions. I have both of those done, but now I am stumped on how to get a shortcut to run the script. I have tried runas as well as powershell -credential and neither seem to be able to both authenticate as well as run the script, i tend to get one or the other. Has anyone been successful in something like this? The use case is the shortcut would reside on a terminal server that is in a different domain than the domain controller we’d be querying, thus the need to authenticate with different credentials.

Thanks in advance for any insights you can give me, hope this makes sense.


function Remove-UCMUser { Param( [Parameter(Position=0,Mandatory=$true)] [string[]]$UserName, [Parameter(Position=1,Mandatory=$true)] [string]$Domain ) #endparam foreach ($User in $UserName) { # remove IP Phone value, telephonenumber value Get-ADUser -Identity $user -properties officephone -Server $domain | Set-ADUser -OfficePhone $null Get-ADUser -Identity $user -properties ipPhone -Server $domain | Set-ADUser -Clear ipPhone } #foreach } #function $username = Read-Host -Prompt "Please specify usernames(s) to be removed. Use commas to separate multiple usernames" $domain = Read-Host -Prompt "Please specify a fully-qualified domain name" Remove-UCMUser -UserName $username -Domain $domain Get-ADUser -Identity $username -Properties ipphone,officephone -Server $domain| foreach{ If($_.officephone -eq $null) { write-host "Success!" } else { write-host "Failure!" } #end else }#end foreach 

submitted by /u/timeconsumer2113
[link] [comments]

Leave a Reply