Jump to content

rsaddul1

Members
  • Posts

    12
  • Joined

  • Last visited

Reputation

0 Neutral

1 Follower

About rsaddul1

Personal Information

  • Location
    Surrey
  1. The two we use are: Office 365 Education for Students (students) & Office 365 Education for Faculty (staff)
  2. PM me and I may be able to help, I believe I have a powershell script.
  3. Hi Guys, Was wondering if there was any update howartp or steve Thanks
  4. rsaddul1

    Deleting Files

    Hello, I was hoping you can help? I am trying to achieve the below: 1) Copy 2 newest files from Scripts to Test and show this in a log. The log must show if has failed or been a success. This log to be sent in an email. 2) Delete any files in Scripts older than 365 days My Code is: # Moves latest two files Get-ChildItem 'C:\scripts' -File | Sort-Object -Property CreationTime -Descending | Select-Object -Last 2 | Copy-Item -Destination 'C:\TEST' -Force $Path = "C:\scripts" $Daysback = "-365" $CurrentDate = Get-Date $DatetoDelete = $CurrentDate.AddDays($Daysback) Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -WhatIF # Creates Log File $logProgress = 'C:\scripts\scriptlog.log' $source = 'C:\scripts\*.txt' $destination = 'C:\TEST' $txtfiles = get-childitem $source -recurse | Select-Object FullName foreach ($file in $txtfiles) {Move-Item -Path $file.FullName -Destination $destination -Force -ErrorAction SilentlyContinue if($? -eq $false){Write-Output "$($file.FullName) did not copy ok to $destination" | out-file -append $logProgress} else {write-output "$($file.FullName) copied OK to $destination" | out-file -append $logProgress} }
  5. Hello, Can anyone help? I am trying to achieve the below: 1) Copy 2 newest files from Scripts to Test and show this in a log. The log must show if has failed or been a success. This log to be sent in an email. 2) Delete any files in Scripts older than 365 days My Code is: # Moves latest two files Get-ChildItem 'C:\scripts' -File | Sort-Object -Property CreationTime -Descending | Select-Object -Last 2 | Copy-Item -Destination 'C:\TEST' -Force $Path = "C:\scripts" $Daysback = "-365" $CurrentDate = Get-Date $DatetoDelete = $CurrentDate.AddDays($Daysback) Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -WhatIF # Creates Log File $logProgress = 'C:\scripts\scriptlog.log' $source = 'C:\scripts\*.txt' $destination = 'C:\TEST' $txtfiles = get-childitem $source -recurse | Select-Object FullName foreach ($file in $txtfiles) {Move-Item -Path $file.FullName -Destination $destination -Force -ErrorAction SilentlyContinue if($? -eq $false){Write-Output "$($file.FullName) did not copy ok to $destination" | out-file -append $logProgress} else {write-output "$($file.FullName) copied OK to $destination" | out-file -append $logProgress} }
  6. Sorry for the confusion. I am trying to achieve the below: 1) Copy 2 newest files from Scripts to Test and show this in a log. The log must show if has failed or been a success. This log to be sent in an email. 2) Deleted any files in Scripts older than 365 days Thanks RS
  7. However, it does copy all files, which is an issue. The code at the top is supposed to copy the two latest files. It seems that the bottom code is affecting it and copying everything now?
  8. Thanks so much. You have resolved this so promptly! I'm going to be cheeky now and ask if you know what code to add to send the log file in an email? Thanks Rsaddul
  9. Hello, I am very new to Powershell hope someone can help. I hope you can help with the below bit of code? For some reason, it does not show the two files copied successfully. Instead, it tells me all files did not copy ok. The error message is shown below: copy : Illegal characters in path. At C:\Users\rsaddul1.318\Desktop\log.ps1:20 char:1 + copy $_.fullname $destination -Force -Recurse -errorAction silentlyCo ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (http://awscdn.cdngeek.com/images/smilies/smile.png [Copy-Item], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Comm ands.CopyItemCommand My Script is below: # Moves latest two filesGet-ChildItem 'C:\scripts' -File |Sort-Object -Property CreationTime -Descending |Select-Object -Last 2 |Copy-Item -Destination 'C:\TEST' -Force # Delete all Files in C:\temp older than 365 day(s) $Path = "C:\scripts" $Daysback = "-365" $CurrentDate = Get-Date $DatetoDelete = $CurrentDate.AddDays($Daysback)Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } |Remove-Item -WhatIF # Creates Log File $logProgress = 'C:\scripts\scriptlog.log' $source = 'C:\scripts\*.txt' $destination = 'C:\TEST\*.txt' get-childitem $source -recurse | foreach {copy $_.fullname $destination -Force -Recurse -errorAction silentlyContinueif($? -eq $false){echo "$($_.fullname) did not copy ok to $destination" | out-file -append $logProgress} else {write-output "$($_.fullname) copied OK to $destination" | out-file -append $logProgress} }
  10. Hello, I am very new to Powershell. I hope you can help with the below bit of code? For some reason, it does not show the two files copied successfully. Instead, it tells me all files did not copy ok. The error message is shown below: copy : Illegal characters in path.At C:\Users\rsaddul1.318\Desktop\log.ps1:20 char:1+ copy $_.fullname $destination -Force -Recurse -errorAction silentlyCo ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [Copy-Item], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Comm ands.CopyItemCommand My Script is below: # Moves latest two files Get-ChildItem 'C:\scripts' -File |Sort-Object -Property CreationTime -Descending |Select-Object -Last 2 |Copy-Item -Destination 'C:\TEST' -Force # Delete all Files in C:\temp older than 365 day(s)$Path = "C:\scripts"$Daysback = "-365"$CurrentDate = Get-Date$DatetoDelete = $CurrentDate.AddDays($Daysback)Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -WhatIF # Creates Log File$logProgress = 'C:\scripts\scriptlog.log'$source = 'C:\scripts\*.txt'$destination = 'C:\TEST\*.txt'get-childitem $source -recurse | foreach {copy $_.fullname $destination -Force -Recurse -errorAction silentlyContinueif($? -eq $false){echo "$($_.fullname) did not copy ok to $destination" | out-file -append $logProgress} else {write-output "$($_.fullname) copied OK to $destination" | out-file -append $logProgress}} Regards RSaddul
  11. Hello, I was wondering if you could shed any light on an issue we currently have at our school. We are an option 1 LGFL school, therefore our firewall is looked after by LGFL. We have an external vendor called Lan3 which currently support our Aerohive (WiFi System). We don't control our firewall as it is managed by LGFL. Unfortunately they don't support and won't configure BootP or DHCP-Relay. This has now put us in a predicament since we have all traffic routed through the firewall. Bare in mind we are using VLANS for the WiFi and we don't want to result in having everything on a default vlan. How did you manage to get this working? Regards Rhys
  12. Hello Bossman, I was wondering if you could shed any light on an issue we currently have at our school. We are an option 1 LGFL school, therefore our firewall is looked after by LGFL. We have an external vendor called Lan3 which currently support our Aerohive (WiFi System). We don't control our firewall as it is managed by LGFL. Unfortunately they don't support and won't configure BootP or DHCP-Relay. This has now put us in a predicament since we have all traffic routed through the firewall. Bare in mind we are using VLANS for the WiFi and we don't want to result in having everything on a default vlan. How did you manage to get this working? Regards Rhys
×
×
  • Create New...