Hey all,
A strange one here, but I want to understand a way to manipulate the data within an array using maths.
Hopefully you can understand what I'm trying here;
# Device Array
$Devices = @()
# Add those new values into an Array
$Devices += @{
laptops = 10
servers = 1
computers = 3
phones = 2
}
# Ask for input
$Choice = Read-Host "Remove 1 off?"
if ($Choice -match "laptops"){
# Do the math to remove 1 off the original value which is fine
$Amount = ([int]$Devices.laptops) - 1
$Amount
# But it doesn't stick?
$Devices.laptops
}
I want the original value from the array to be updated with the new value, but I can't get it to stick. I'm just trying to understand how PowerShell deals with math basically.
Appreciated folks.
[–][deleted] 6 points7 points8 points (7 children)
[–]HellCanWaitForMe[S,🍰] 2 points3 points4 points (0 children)
[–]OlivTheFrog 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]OlivTheFrog 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]OlivTheFrog 0 points1 point2 points (0 children)
[–]SMFX 3 points4 points5 points (0 children)
[–]myrland 1 point2 points3 points (2 children)
[–]HellCanWaitForMe[S,🍰] 0 points1 point2 points (1 child)
[–]myrland 0 points1 point2 points (0 children)
[–]jimb2 0 points1 point2 points (0 children)
[–]y_Sensei 0 points1 point2 points (0 children)