PowerShell Script or Batch Script to move a file if name already exists.
Spiceworks » PowerShell
by Oscar-3
4h ago
Could use some help / guidance. We have our Employee Photos on a network drive that are all named by their 6 digit employee ID number. Employees take pictures yearly and we like to archive photos as they are being uploaded if they already exist in the parent folder we move them over to the "Old" subfolder. I would like to automate this process. Is it possible to create a Powershell Script or Batch Script that is actively running every time a picture is uploaded to this "EmployeePhotos" folder? These are uploaded via SMB on an iPad. If ID badge already exists could this script rename / move o ..read more
Visit website
Run With Powershell never lets the script do what it's intended to do
Spiceworks » PowerShell
by SysadminToBe
6h ago
**I've written the following script for my laptops:** Can someone tell me why it only runs and does what it's intended to do if I copy-paste the content into a powershell window (standard user, not admin) and click 'Run' (or press Enter)? In other words, right click on ps1 script -> Run With Powershell never lets the script do what it's intended to do. It runs from start to finish BUT the network drives are never mapped. Powershell # Define the list of network drives to map $networkDrives = "\\MyNAS\cracked games", "\\MyNAS\dummy folder", "\\MyNAS\Videos", "\\MyNAS\Images", "\\M ..read more
Visit website
Change Registry Value REG_SZ with Powershell GPO
Spiceworks » PowerShell
by spicehead-ex7x8
10h ago
Hi, I am trying to change the value of registry REG_SZ using powershell, but for some reason the Powershell doesn't know how to change REG_SZ , only DWORD registries, if I insert "String" as "Type" it creates the GPO but it provides the next error inside Group Policy Management "Display names for some settings cannot be found. You might be able to resolve this issue by updating the .ADM files used by Group Policy Management." HKLM\System\CurrentControlSet\Services\W32Time\Parameters Type = NT5DS Script is: Text $Pol = New-GPO -Name ITTime -Comment 'ITTime' -Domain corp.com $Pol.GpoStatus ..read more
Visit website
How to format and export to excel from Powershell
Spiceworks » PowerShell
by Foddo
10h ago
this is my script, Clear-Host Clear # Prompt user for UNC path $uncPath = Read-Host "Enter a UNC Path: " # Split UNC path to get computer name and share name $pathParts = $uncPath.split("\") $computerName = $pathParts[2] $shareName = $pathParts[3] # Add the file server to the trusted hosts list Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$computerName" -Concatenate -Force # Create a new remote session to the file server $cred = Import-Clixml -Path "C:\temp\script\creds.xml" $session = New-PSSession -ComputerName $computerName -Credential $cred # Get share description $share = I ..read more
Visit website
Why does Run With Powershell not run my script correctly?
Spiceworks » PowerShell
by SysadminToBe
19h ago
Copy-pasting the script into a powershell window where the beginning says "PS C:\Users\MyUsername" and then running it works perfectly and the script does what it's supposed to But when I right-click on it and choose Run With Powershell, it doesn't work. Why is this and how can I fix this? Thanks. Things to note: If I run it as admin, it doesn't work. If I run it as standard user from my home directory (open powershell window -> it says PS C:\Users\MyUsername), it works perfectly. So apparently when I right-click on it and choose Run With Powershell, it doesn't run from inside the user's ho ..read more
Visit website
Parse secure password into promote DC
Spiceworks » PowerShell
by spicehead-ex7x8
21h ago
Hi, I want to promote one of my VM's to DC using powershell, I managed to find a way to do it with encrypting the password and parsing it into a .txt file but I want to automate the promotion of my DC's from now on, is there any other way I can do it, just for the password to be inside the script without me writing inside the input of read-host or get-credential? my script: Text $username = "corp\administrator" $password = "MyPas$word" | ConvertTo-SecureString $password2 = $password $credential = New-Object System.Management.Automation.PSCredential -argumentlist $username, $password Install ..read more
Visit website
Restart vs Windows Restarting vs Shutdown and start up
Spiceworks » PowerShell
by Terry8061
23h ago
Hello I can't seem to figure out programmatically, what the os differentiates between a user selecting "Restart", Windows Rebooting after an update, and when a user shuts down, then starts the computer. If I write some code to tell me if a computer hasn't restarted in 7 days, it does not always tell the truth. If a user reboots, then it's considered a restart.  If windows reboots, the computer does not register that as a "restart", if a user shuts down, then starts the computer (in the morning), again, it is not recognized as a restart. Is there a way to programmatically check for each sc ..read more
Visit website
Combining results to show in a out-gridview
Spiceworks » PowerShell
by Wingers
23h ago
Hi I have a script to get installed versions of a specific app from a list of computers, so the below would show me a grid with two columns showing PSComputerName and DisplayVersion which works fine. Powershell $installed = Invoke-Command -ComputerName $remoteworking { param($regpath, $software) Get-ItemProperty $regpath | Where-Object { $_.DisplayName -like $software } } -ArgumentList $regpath, $software $softwarealreadyinstalled = $installed | Select-Object -Property PSComputerName , DisplayVersion -Unique | Out-GridView I would like to also retrieve logged on user name, and be able to s ..read more
Visit website
Help with logic please
Spiceworks » PowerShell
by Terry8061
23h ago
Hello I have 2 conditions either could be true or false. They both return a string if they are not null. Powershell $FN = If((Test-PendingReboot -SkipConfigurationManagerClientCheck).IsRebootPending -eq $True) {Return "A File Rename is Pending";} Powershell $D7 = If($dys -gt 7){Return "Has not Rebooted for at least 7 Days";} $dys is just a calculation to see if a computer has been rebooted in the last 7 days or not. So, I want to output a message; something like "your system needs a reboot. Reason: ........ " If $FN is not null, then Reason: $FN If $D7 is not null, then Reason: $D7 If ..read more
Visit website
Cannot create a file when that file already exists.
Spiceworks » PowerShell
by spicehead-31qkz
1d ago
Hello, I currently have a PS script that trims files names and renames them. Here is the script that works well. Powershell get-childitem -path | Rename-Item -NewName {$_.name -replace "000","" -replace "_file",""} Is there a way to modify the script so that when it encounters a similar file name it overwrites it. Right now, I get the following error when the script runs and it encounters an already existing file with the same name:Cannot create a file when that file already exists ..read more
Visit website

Follow Spiceworks » PowerShell on Feedspot

Continue with Google
Continue with Apple
OR