Jump to content

eDecisions

Members
  • Posts

    56
  • Joined

  • Last visited

About eDecisions

  • Birthday 05/01/1962

Profile Information

  • Gender
    Male
  • Location
    Sacramento Ca
  • Interests
    67 Camaro :)

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Did this a long time ago... This one maps a drive letter to the server for the logged in user, you can work backwards to do anything, basically you have to create a task to make it happen that runs once on demand as the local user: $Taskname = "netuse" $lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $Taskname /RU $lastlogon /TR "c:\maplist.bat" start-sleep -s 1 New-Item c:\maplist.bat -ItemType "file" Set-Content c:\maplist.bat 'net use t: "\\twdserver\Shared\SERVER - Documents" /persistent:yes' schtasks /Run /TN $Taskname start-sleep -s 1 schtasks /delete /tn $Taskname /f
  2. Made one change this morning after testing, the log file is 50+ pages, I only really need to see the last 10 to 20lines of the log to see how things are going, added the -tail 20 to return the last 20 lines, tested this morning, I imagine next step would be to combine this for any/all longs I want and export to a text file and email as a daily summary. $dir = "C:\aktdata\quickbooks\Sync_Reports" $filter="*.txt" $latest = Get-ChildItem -Path $dir -Filter $filter | Sort-Object LastAccessTime -Descending | Select-Object -First 1 $latest.name Get-Content $dir"\"$latest -tail 20
  3. Not my work, I took code form two locations and put them together to fit my needs, change the path to the path to your folder, change the filter to the file type to filter by, add as a script, run it, and then open your Last Executions to see the contents of the file. I was needing to check status of a log file on a server every so often, the log file name would change daily and be time stamped, this solved it for me. $dir = "C:\data\Sync_Reports" $filter="*.txt" $latest = Get-ChildItem -Path $dir -Filter $filter | Sort-Object LastAccessTime -Descending | Select-Object -First 1 $latest.name Get-Content $dir"\"$latest
  4. sure I could do that as well and have a few customers doing that, I'm looking for a zero server touch however, and the ability to bring a new printer into a company and not have to touch the server, I have an onboarding task that does all my pc setup, so I want to add printers this way, little more up front work but once done I can get a call from any office, hay ken we just purchsed an HP xyx printer can you come set it up on my computer. CLICK done I've added 3 printers already I can do this with at any office, I've even managed to scan the network for the likely IP address of the printer, get its name and add a port by printer name. its clunky right now but heading in the correct direction.
  5. I did this for NINJA, try playing with the search key where the -match "your program" but be carefull $UninstallString = (Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\NinjaRMMAgent*).UninstallString sleep -seconds 2 if (!$UninstallString) { exit } sleep -seconds 2 $path = $UninstallString -replace "uninstall.exe", "" sleep -seconds 5 cd $path sleep -seconds 5 Start-Process -FilePath .\uninstall.exe -ArgumentList "--mode","unattended" sleep -seconds 40 $Uninstall2 = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match "NinjaRMMAgent" } | Select-Object -Property UninstallString | foreach { $_.UninstallString } sleep -seconds 220 $Uninstall3 = $Uninstall2 -Replace "MsiExec.exe " , "" sleep -seconds 5 Start-Process -FilePath MSIExec.exe -ArgumentList $Uninstall3,"/quiet","/passive"
  6. I want to start a project, ADD-Printer via power shell, anyone want to help? Or you doing it alrady?
  7. I used a few times now and its about 90%, about 10% of the time my script fails to find the program, if anyone has any thoughts on what I missed please share.
  8. Darn, missed the fact that I was in session 0, ooops my bad, this should add to all active users. $Officepath = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe\Path") $Profiles = Get-ChildItem 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileList' | ForEach-Object { $_.GetValue('ProfileImagePath') } foreach ($profile in $profiles -match "Users" -notmatch "spfarm" -notmatch "spsearch" -notmatch "TEMP" -notmatch "Classic"){ $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Profile\Desktop\Excel.lnk") $Shortcut.TargetPath = "$Officepath\Excel.exe" $Shortcut.Save() $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Profile\Desktop\Outlook.lnk") $Shortcut.TargetPath = "$Officepath\Outlook.exe" $Shortcut.Save() $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Profile\Desktop\Word.lnk") $Shortcut.TargetPath = "$Officepath\Winword.exe" $Shortcut.Save() }
  9. Great for onboarding new station, you can grab any other short cuts such as to shared rive, or network folders, the users C drive or the my documents folder as well, I just did the office apps. #By eDcisions $Officepath = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe\Path") $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\Excel.lnk") $Shortcut.TargetPath = "$Officepath\Excel.exe" $Shortcut.Save() $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\Outlook.lnk") $Shortcut.TargetPath = "$Officepath\Outlook.exe" $Shortcut.Save() $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\Word.lnk") $Shortcut.TargetPath = "$Officepath\Winword.exe" $Shortcut.Save()
  10. What I started doing was creating Script Groups, hence every customer has their own set of scripts, however the point of this one was a little different, imagine you just want to map a drive for today between 2 computers at the office for the client, this works. If you'd like to get rid of the copy file first, conciser building the file first in powershell with the commands, and then call that file, and delete it after run. I did that with the "SHOW MAPPED DRIVES OF LOGGED IN USER" that I just posted, take a peek of how I wrote a local batch file and then ran it and deleted it. Script Group Specific customer 1 >Map drives Specific Customer 2 >Map Drivers Specific customer 3 >Map Drives
  11. I think thats the case, I submitted a request for info on the new feature and was told they were still working on it. So maybe this is just a pre-release, in its current form its not very usefull to me.
  12. Ok this guy will display the users mapped drive of the user thats logged into the pc as well as the status of the drive, disconnected, Ok, ect... Nice if you's setting up another pc remotely and you want to see what the shared drives on another users pc were so you can match them. #by eDecisions $Taskname = "netuse" $lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $Taskname /RU $lastlogon /TR "c:\maplist.bat" start-sleep -s 1 New-Item c:\maplist.bat -ItemType "file" Set-Content c:\maplist.bat 'net use >> c:\maplist.txt' schtasks /Run /TN $Taskname start-sleep -s 1 schtasks /delete /tn $Taskname /f get-content -path c:\maplist.txt del c:\maplist.txt del c:\maplist.bat
  13. its not expected to run as a stand alone script, I set this so I could run from the powershell instance, so you'd save the script above into a working folder on the client, could could call it anything you like with a ps1 Then from the power shell window you can type c:\mypath\myname.ps1 x: \\server\share were taking the %1 and %2 as $args0 and $args1, so you're completing the 2 items when you manually type the command in the powershell windows. hope that makes sense.
  14. way too much work, this adds a script by currently logged in use or last logged in user if system is logged off, note this is a powershell script, also I set its start time for before current time so it will only run if you manually start it but do what you will. #By eDecisions $TasknameStop = "ExplorerStop" $TasknameStart = "ExplorerStart" $lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $TasknameStop /RU $lastlogon /TR "taskkill /f /im explorer.exe" SCHTASKS /CREATE /sc ONCE /st 00:00 /TN $TasknameStart /RU $lastlogon /TR "explorer.exe" start-sleep -s 1 schtasks /Run /TN $TasknameStop start-sleep -s 1 schtasks /Run /TN $TasknameStart start-sleep -s 1 schtasks /delete /tn $TasknameStop /f schtasks /delete /tn $TasknameStart /f
×
×
  • Create New...