User Profile
John_Dodo
Brass Contributor
Joined Dec 13, 2021
User Widgets
Recent Discussions
Re: Refresh Enterprise Mode Site List
Kelly_Y Hi Kelly, The version of Edge is the following: 125.0.2535.51 For my part, we deliberately blocked the version of Windows 10 1809 on our VDI, to keep Internet Explorer (business application compatibility), and not move to Edge Chromium. Since then, for corporate security reasons, we've opted to ugrade to Windows 10 20H2 (then 22H2 shortly) with the latest versions of Edge Chromium (updated weekly). Currently 125.0.2535.51, soon 125.0.2535.67 Would you have an alternative way of benefiting from Refresh Enterprise Mode Site List without having Edge Chromium running in the background for 65 seconds and without clicking on the Force Update button? Thank you in advance for your help.923Views0likes1CommentRe: Refresh Enterprise Mode Site List
Hi Kelly_Y, here May 2024 and still having this issue with recent versions. Only clicking edge://compat/enterprise allows to not close Edge to get to compatibility mode. This is clearly not a usable solution for an enterprise. Edge : 125.0.25.35.51 IE : 11.0.19041.1566 Windows 10 : 20H2 build 19042.2965 Thank you for your help.967Views1like4Commentsstruggling with parralele tasks
Hi, I'm trying to improve my code by using parrallele tasks. I'm struggling with testing the connections. $cpt = get-adcomputers -filter * $s = New-PSSession -ComputerName $Srv_list.DNSHostName $WSUSjob = Invoke-Command -session $s { write-host $(hostname) } } -JobName WSUSjob -AsJob $j = Get-Job $results = $j | Receive-Job I would know how to test a connection with a foreach and a try catch on a SINGLE computer, but what would be the right way of handling the result of the New-Pssession when using it directly on an ARRAY ? In my example it works and open sessions on answering computers. But I don't know how to retrieve the ones that didn't answer. Thank you.469Views0likes1CommentRun Get-Aduser from Get-Adgroupmember with users from sub-domains
Hello, I running is script that retrieves users from a group in ad.local The users within can be from ad.local and/or subdomain1.ad.local, subdomain2.ad.local etc When I run (from a computer that is part of subdomain1.ad.local) $userlist = get-adgroupmember -Identity $object_name -Server $object_ad -Credential $mycreds foreach ($user in$userlist){ $userad= Get-ADUser -Identity $($user.distinguishedName) } => I get Get-ADuser : A referral was returned from the server I tried this : Get-ADUser -Identity $($user.distinguishedName) -server "usersdomain" -Credential $mycreds It works. But get-adgroupmember only returns distinguishedName : CN=jdoe,OU=Users,DC=subdomain1,DC=ad,DC=local name : jdoe objectClass : user objectGUID : 2293fd35-9fa7-4acc-a22f-5799f6dd2369 SamAccountName : jdoe SID : S-1-5-21-1231254564-630871074-310601177-1324 Do you know how I can retrieve the users domain (ex : "subdomain1.ad.local" or "ad.local" etc) without having to manipulate distinguishedName ? Thank you for your help.2.3KViews0likes1Commentretrieve rows with highest values in from array
Hi, I'm struggling a bit with something that should be easy ... I import a CSV and then I want to retrieve the rows with highest value for different "families". Ex: col1;col2;col3;col4 dateA;child1;son1;4 dateB;child2;son2;1 dateC;child2;son1;5 dateD;child1;son1;2 dateE;child1;son3;4 dateF;child1;son3;3 dateG;child2;son2;4 In here, I would like to get an new array with only col2;col3;col4 familly1;child1;4 familly1;child3;4 familly2;child2;4 familly2;child1;5 I have tried doing a foreach in a foreach but I'm still struggling with the two level depth of family and child Here is what I started to do : $tab = Import-Csv -Path $file -Delimiter ";" -Header "col1","col2", "col3" #This sort is probably not needed but I'm trying... $tabsorted = $tab | sort-object -property @{expression = "col2"; Descending = $true }, @{expression = "col3"; Descending = $true }, @{expression = "col4"; Descending=$true} $dummyfamilies= $tab | Select-Object -property "col2","col3" -Unique $tabtemp = @{} $count = 0 foreach($familly in $dummyfamilies) { foreach ($row in $tabsorted){ #this is the painful part if( (( $row.col2 = $family.col2) -and $row.col3 = $family.col3) -and #here i'm lost ($tabtemp.col2.col3.Maxvalue -gt $family.col4)){ $tabtemp = @{family = $row.col2; son = $family.col3; Maxvalue = $row.col4} # something like this... } } } Well something like this. Thank you for your help.857Views0likes1CommentStruggling with double hop and credential management
Hi all, I have a setup where I use a powershell host to run scripts. These scripts are triggered from vmware Orchestrator and the scripts are manipulating files on a remote share. vRo => PSH => RemoteShare Therfor I am in a double hop situation and I need to handles the credentials. I use this solution : https://www.pdq.com/blog/secure-password-with-powershell-encrypting-credentials-part-2/ When doing my tests, I run the script with my personal user account. I use a Fct_ConnectToAD function to create a PSCredentials object, using a service account and the -key option to be able to run the script with any user from any computer (works fine) and still generate the proper PSCredential object. Function Fct_ConnectToAD { $User = "$erviceAccount@$ad" $PasswordFile = "$basefolder\Toolbox\auth.pxt" #$MyCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $PasswordFile | ConvertTo-SecureString -Key (Get-Content $KeyFile)) $MyCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $PasswordFile | ConvertTo-SecureString -Key (Get-Content $KeyFile)) return $MyCredential } #ConnectToAD I use another function Fct_MapPSDrive using the said PScredentials to create a mapdrive to my sharedfolder. function Fct_MapPSDrive { param( [Parameter (Mandatory = $true)] [string] $path, [Parameter (Mandatory = $true)] [string] $name, [Parameter (Mandatory = $true)] [System.Management.Automation.PSCredential] $credential ) New-PSDrive -Name $Name -Root $path -PSProvider "FileSystem" -Credential $Credential -Verbose } [System.Management.Automation.PSCredential] $mycredential = Fct_ConnectToAD Fct_MapPSDrive -path $PSDrivePath -Name $PSDriveName -credential $mycredential It works fine when I am inside my function. But once I get out of it I don't see the drive anymore using get-psdrive. Whether I run the script with my standard account or my service account doesn't make any difference. And Idea on how to perform this? If I can't use the drive then I would have to use the -credential on any single command of all my scripts (ex : new-item -credential $mycredential ...) which is not really a comfortable option... Thank you.Solved771Views0likes1CommentRe: Retrieve executed script information the best way
Template script if you will yes. The section of code I have written in my first message is at the beginning of all my main scripts. I just want to know what is best to retrieve these values. Using $PSSCRIPTROOT method, using $myinvocation or something else.1.8KViews0likes1CommentRe: Retrieve executed script information the best way
Harm_Veenstra Sorry for the late answer. I think my question was not clear enough. Basically I need to set these variables because I want to use them in my scripts (so transcript isn't an option). But as you can see in my code I am using different ways to get the said values. My question was, is there any standardize way to all the values? (Using the same logic for all of them). Still not clear maybe...1.8KViews0likes5CommentsRetrieve executed script information the best way
Hello, I have this piece of code at the begining of most of my script. $ScriptFolderPath = $PSSCRIPTROOT $ScriptFolderName = (get-item $ScriptFolderPath ).Name $BaseFolder = (get-item $ScriptFolderPath ).parent.FullName $ScriptName = $MyInvocation.MyCommand.Name $ScriptNameNoExtension = [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Source) Is there a clean, durable and standardized way of getting all these values (working in PS5 and 7) ? Thank you.2.2KViews0likes9Commentsexit powershell scriptS when imbricated
Hello, I have a script main.ps1 called with parameters "-environment PRD" or "-environment "PILOT". This main script calls a toolbox.ps1 script which is like this : switch ($environment) { "PILOT" { #define PILOT vars } "PRD" { #define PRD vars } default { write-host "!!! No Environment provided !! Closing the script." exit } } This exit seems to only close the toolbox.ps1 script but not the main.ps1 How can I achieve this ? Thank you.1KViews0likes2Commentsreplace robocopy options with copy-item
Hello, I want to get rid of robocopy in some old scripts and use powershell copy-item instead. Here is a typical line : .\robocopy.exe "\\$sourceserver\$sourcefolder" "\\$targetserver\$targetfolder" *.* /r:2 /w:5 /e /purge /purge ask to remove anything at the target that doesn't exists at source. Basically it does a folder sync more than a source folder content copy to the target. /e copies also empty folders /r:2 retries twice if copy errors while /w:5 asks to wait 5 second between every try I mostly concerned with the /purge option. I don't see any option in copy-item that would do a sync of the source and target folder. Do I need to create a function to do it myself or is there any native way of doing it that I'm not aware of? This page suggest that it is not handled by default (see the very last proposal) : https://stackoverflow.com/questions/25869806/how-to-keep-2-folders-in-sync-using-powershell-script Thank you.8.5KViews0likes1CommentUse to upper in pipe
Hello, I'd like to get all my "text" in uppercase right before sending it to CSV. Is this possible and how? (I don't want to do it anytime earlier in my script). I know the "string".ToUpper() method but no idea how to use something similar here. $hash.GetEnumerator() | Sort-Object $_.keys | ForEach-Object{[PSCustomObject]$_.value } | Sort-Object TimeID -Descending | Export-Csv "$hash" -NoTypeInformation -delimiter ";" Thank you.Solved1.5KViews0likes4CommentsPowershell : interprete string as variable name
Hello, I want to importe values from a csv file. Some column have this sort of values : $myvar. So it would be like this : log_message;server;scriptfolder;scriptname;action blabla;myserver;$scriptfolder;$scriptname;letsdance Now let say I want to do something like this : $scriptname = script.ps1 $references = import-csv .\mycsv -delimiter ";" foreach ($ref in $references){ write-host "$($ref.log_message) - $($ref.scriptname) } If I run something like this I get : blabla - $scriptname Is it possible to ask powershell to interprete the value of $scriptname instead of sending the string value $scriptname ? I tried get-variable($reference.scriptname) but I get this get-variable : Cannot find a variable with the name '$scriptname'. though write-host $scriptname script.ps1 Thank you.1.2KViews0likes1Comment
Recent Blog Articles
No content to show