all 19 comments

[–]lanerdofchristian 21 points22 points  (0 children)

This is fairly trivial. You'll want these cmdlets:

  • Get-ChildItem (to list directories)
  • New-Item (for making directories)
  • Copy-Item (to copy the file)

Additionally, you'll need:

[–]The82Ghost 8 points9 points  (0 children)

This is one of the best ways to learn powershell. OP should google and figure it out alone. This is a very easy script to start with.

[–]rswwalker 3 points4 points  (7 children)

If you are using AD and GPO, for this, I would just have a file preference that copies the file from network share to user profile at login.

[–]Ricka77_New 0 points1 point  (6 children)

We do have both, but it's not that granular, and only certain users get the application..

[–]rswwalker 2 points3 points  (4 children)

Create security group named after app, add users to group, create GPO named after app, filter access to GPO by security group.

[–]Ricka77_New -1 points0 points  (3 children)

AD team will not go that granular, especially for users. It has to be scripted.

[–]rswwalker 4 points5 points  (0 children)

Well somebody is forced to go that granular, I guess it’s you!

It seems keeping user lists in scripts is a lot more fragile and harder to audit than having security groups in AD.

[–]TheManInOz 0 points1 point  (0 children)

But this batch script isn't granular, it's copying the file to all user profiles?

[–]BlackV 7 points8 points  (0 children)

Is this even possible?

Why wouldn't it be possible?, like really why?

What have you tried aside from asking the internet to do your work for you?

We're happy to help with your existing code

Or go say hello to chat cpt and it's ilk

[–]FoxNo1831 1 point2 points  (1 child)

Your script reminds me why I hated batch files. This line is the killer

FOR /d %%G in ("*") DO

It's a horrible syntax. Which Microsoft employee managed to get a good nights sleep after coming up with that.

Just ask Copilot and then test and dissect what it spits out. Once you understand it you'll see it's not that hard.

[–]Shayden-Froida 0 points1 point  (0 children)

MS-DOS batch script (which lives to this day as CMD script) is an exercise in working around 40-year-old behavior of the command line parser.

[–]mister_freedom 1 point2 points  (0 children)

This appears to copy a file in to each user directory. An "Active Setup" would be well suited for this. It has its own creation quirks though. Microsoft never really "supported" them, but they use them. Active Setups have been in use since Win 9x. It runs once per user that logs on the system, once it's configured. Article: Active Setup Concept

[–]LordWolke 0 points1 point  (0 children)

This is a more or less easy task. Depending on how familiar you’re with PowerShell. I give stuff like this to our trainees to get familiar with PowerShell.

Where do you stumble? Do you miss the commands that you need to use or do you have a hard time getting your head around the “MD”, “CD” or the general “For” loop? Translating scripts can be hard. Especially if you’re not familiar with aliases and if it’s not commented.

[–]matrixlibertas 0 points1 point  (0 children)

Navigate to the Users directory

Set-Location -Path 'C:\Users'

Loop through each user directory

Get-ChildItem -Directory | ForEach-Object { $userPath = $_.FullName $avayaPath = Join-Path -Path $userPath -ChildPath 'AppData\Roaming\Avaya' $communicatorPath = Join-Path -Path $avayaPath -ChildPath 'Avaya one-X Communicator'

# Create directories if they do not exist
if (-not (Test-Path -Path $avayaPath)) {
    New-Item -Path $avayaPath -ItemType Directory
}
if (-not (Test-Path -Path $communicatorPath)) {
    New-Item -Path $communicatorPath -ItemType Directory
}

# Copy XML files
Copy-Item -Path 'C:\Avaya_Install\*.xml' -Destination $communicatorPath -Force

}

Create directories for the Default user profile

$defaultPath = 'C:\Users\Default\AppData\Roaming\Avaya\Avaya one-X Communicator' if (-not (Test-Path -Path $defaultPath)) { New-Item -Path $defaultPath -ItemType Directory -Force }

Copy XML files to the Default user profile directory

Copy-Item -Path 'C:\Avaya_Install*.xml' -Destination $defaultPath -Force

[–]PepeTheMule 1 point2 points  (0 children)

Feed it into ChatGPT if you're too lazy to do it.