I am attempting to create a powershell script that can perform the following:
1-Filter by Get-Group on a device via an installed xml file.
2-Only perform the copy function if the group equals Get-Group.
So far, the only thing I've succeeded in having it copy the first or the last file, on an incorrect device. I believe you can only use 2 IF statements a single powershell script? If so, how would I achieve this result I am looking for? I've also tried ElseIF, Else, Switch, and WhatIF with no joy. I have also tried different arguments for the IF statements. -eq, =, -like, and -match. None of which seem to be overly helpful in this situation.
$ActiveFilePath = "C:\ProgramData\JKCS\jkupdate\jku.ini"
Function Get-Group
{$Group = ([xml](Get-Content D:\Tools\SystemInformation\SystemInformation.xml)).'system-information'.'device-group'}
Get-Group
If ($Group -eq "XXXXX101Master")
{Copy-Item ".\JKU Files\101\jku.ini" "$ActiveFilePath"}
#----------------------------------------------#
If ($Group -eq "XXXXX102Master")
{Copy-Item ".\JKU Files\102\jku.ini" "$ActiveFilePath"}
#----------------------------------------------#
If ($Group -eq "XXXXX103Master")
{Copy-Item ".\JKU Files\103\jku.ini" "$ActiveFilePath"}
#----------------------------------------------#
If ($Group -eq "XXXXX104Master")
{Copy-Item ".\JKU Files\104\jku.ini" "$ActiveFilePath"}
#----------------------------------------------#
If ($Group -eq "XXXXX105Master")
{Copy-Item ".\JKU Files\105\jku.ini" "$ActiveFilePath"}
#----------------------------------------------#
If ($Group -eq "XXXXX106Master")
{Copy-Item ".\JKU Files\106\jku.ini" "$ActiveFilePath"}
$Groupafter callingGet-Group. We don't have that file (I think), so we can't really test it for you.$Group = Get-Groupor use scope assignments.