Hello everybody, i’m coming to you with a strange problem.
Here is a summary:
I’m working on a script for work to do a lot of different actions on Active directory.
Two of those action are “Get who is a member of this group” and “What groups is this user a member of”
It works really fine when i just launch the PS1 and everything is good.
BUT
I want to integrate all my scripts in a main script that can launch module, so i took my script and made a PSM1 that i can load from my “main menu” But when i do that, i don’t get anything from my requests.
Here are the active parts that works fine by themselves but not in a module:
[pre] Function inventaire {
$Grpinventaire = read-host “entré le nom du groupe”
$infoMember = Get-AdgroupMember $grpinventaire -server “"
foreach ($member in $infoMember) { get-aduser -server "” $member.samaccountname -properties displayname | select displayname,name }
pause
} [/pre]
[pre]
Function inventaireUT {
$UT = read-host “entrer le matricule de l’utilisateur”
get-ADPrincipalGroupMembership -identity $UT -server “*****” | select name
pause[/pre]
And there is how i load the module containing those functions
[pre]
#Menu principal#
function Show-Menu-main
{
param (
[string]$Title1 = ‘Regroupement Script N2 par Kevin LION’
)
Clear-Host
Write-Host “================ $Title1 ================” -ForegroundColor yellow -BackgroundColor Black
Write-Host “1: Ajout/suppression de groupe AD” -BackgroundColor Black -foregroundcolor green
Write-Host "2: Obtention d’information sur compte AD/groupe "-BackgroundColor Black -foregroundcolor green
Write-Host “3: Administration du proxyadresse sur compte AD”-BackgroundColor Black -foregroundcolor green
}
#Fonction de menu#
function menu-main
{
switch ($selectionmain)
{
‘1’ {
import-module admanpo #This is the module with my non-working script#
} ‘2’ {
Import-module still need to create this one
} ‘3’ {
Import-module AliasManpo
} ‘q’ {
exit
}
}
}
#Debut du programme partie active#
While ($selectionmain -ne “q”) {
show-menu-main
$selectionmain = read-host “entre un chiffre”
menu-main
}
[/pre]
I tried to launch the menu in administrator and in normal mode and still the same, i don’t have any error message, it just doesn’t give me anything as a result.
I’m sorry if its not clear enough, i’ll edit the message if anymore information is needed.