# Tag Info

1

A clean solution that doesn't leave any half baked open references like the sample from pk does is: $driveEject = New-Object -comObject Shell.Application$driveEject.Namespace(17).ParseName("E:").InvokeVerb("Eject") Retrieved from http://sushihangover.blogspot.nl/2012/02/powershell-eject-local-or-remote.html

0

This link here helped me to solve my problem: http://rcmtech.wordpress.com/2011/06/09/how-to-get-clientname-within-logon-script-on-server-2008-r2-xenapp-6/ Now I am parsing the output of qwinsta and read the clientname from the registry which is earlier available then the var %CLIENTNAME% Function Get-ClientName { $session = qwinsta$env:USERNAME ...

0

The output from -x goes to stderr, not stdin. But even that can be a problem -- plenty of scripts will have functional dependencies on the content of stderr, and its kind of messy to have the debug and stderr streams mixed together in some cases. Bash versions > 4.1 do offer a different solution: the BASH_XTRACEFD environment variable allows you to ...

0

Yes I was thinking about that. I was thinking the script below could catch the email from STDIN and feed it to a file but this file would need to be unique so I was thinking something along the lines of using the date command up until the milliseconds just in case more than 1 person sends an email at the same time. The file must be unique. Also the proper ...

1

You can create a cmdlet for this, so you can also use it in your command line: Cmdlet param( [string]$folder, [int]$expiry ) ls $folder | % { if ($_.LastWriteTime -le (date).AddDays(-$expiry)) { rm$_ -fo } } Usage .\script.ps1 -folder "c:\logs\iis\siteA\" -expiry 30 .\script.ps1 -folder "c:\logs\job1\" -expiry 60 .\script.ps1 -folder ...

6

Edited to include your requested text file of c:\logs\iis\siteA\ -30 c:\logs\job1\ -60 e:\archive\clientA\ -90 I tested the new bits of code separately from what I had lying around, but it should still do what you want, I think. $controlfile = "c:\path\to\yourfile.txt"$curr_date = Get-Date New-Item -ItemType directory -Path f:\delete foreach ...

0

With an lsof -p pidof find you can see, where is your find command currently. With a strace -p pidof find you can check, what it is doing currently. None of them have really beautiful output - they are debug tools, but the little bit of learning their output is also really useful.

5

Your understanding is correct. When your company gets to the size that you need to bring in a dedicated Windows sysadmin they're going to be unhappy that you did this. I can't imagine that your logic is so complex that it couldn't be solved by the built-in functionality in Group Policy. Security Group filtering, WMI filtering (which is ...

0

Your understanding is correct, but when the computer is starting up, you might end up your script changes not working in case of conflict and priority settings (e.g. the GPO which has the startup script runs first, and then there is another GPO that modifies that value) GPO modeling provides you with a single view of what configuration is in place. When you ...

0

I recently undertook a similar project and after looking into good ol' GPO push method vs. newer GPP vs. scripting, I chose for scripting the whole thing. I have no idea what would work best for you but here are a couple of pointer for you: Ideally use a client with a new OS (Windows 8/2012+) to connect to print servers and get Printer information from ...

8

Powershell management of Group Policy sucks w/o third-party (commercial) products, in my opinion. I think you're stuck slinging through the XML (or in HTML if you prefer) in Group Policy Objects to do what you're looking for. Fortunately the XML doesn't look that terrifying. The per-printer UID value (which I believe is what @KatherineVillyard is referring ...

7

I googled pretty hard, and even toyed with backup-GPO in hopes of being able to hack the resultant XML file and reimport it, but I suspect that a PowerShell script is in your future. It's not that bad. You can generate the printer list from the nearest server and then loop through that and map them. Something like this: $net = New-Object -COMObject ... 1 Yes. You can do this with powershell similar to what the script you posted tries to do. I came across that script a while back, can't remember if it worked or not but I did get something to work. don't know why his wouldn't work, it does use the same methods, but I was able to do this with .NET and WMI using C#, so I know it can be done with powershell. ... 1 If you want to define multiple files in a directory without recursing the whole directory, you can use an array - like this:$myfiles = [ "/my/dir/file1", "/my/dir/file2", ], file { $files: ensure => "present", owner => "root", group => "root", mode => 0644, source => "puppet:///modules/someprogram/$fqdn/$name", } ... 0 It may be more beneficial to you to lower the Group Policy Refresh Interval on these servers to 5-10 minutes rather than executing a remote gpupdate on all of your servers. 3 You can do what you are trying with this: file { "/etc/someprogram/config": ensure => directory, recurse => remote, source => "puppet:///modules/someprogram/files/$fqdn" #Other options } This will copy all of the files in $fqdn to /etc/someprogram/config, overwriting if they already exist. 1 Presumably you're running the task as the logged-on user's identity (the user who has the machine locked). Provided you have granted appropriate permission for that user to logon locally to the server computer and, provided you configure the Task Scheduler entry the same way as you have on the Windows 7 machine, I wouldn't anticipate any problems. ... 4 How about:$WshShell = New-Object -comObject WScript.Shell $Shortcut =$WshShell.CreateShortcut("$env:PUBLIC\Desktop\oldapp.lnk")$oldargs = $Shortcut.Arguments$Shortcut = $WshShell.CreateShortcut("$env:PUBLIC\Desktop\newapp.lnk") $Shortcut.TargetPath = "%ProgramFiles%\appdir\app.exe"$Shortcut.Arguments = \$oldargs -replace "server1", "server2" ...

0

Okay I have an idea. Register your own domain name Point the DNS to this IIS server that you have Set up a password protected site that only accepts connections on 443 Enable directory browsing Put a bunch of files in there, no index (unless you wanted to share files over a fancy html page) That is how I would do it. That way, they are going over HTTPS, ...

Top 50 recent answers are included