$props = ($File | get-member -MemberType NoteProperty)
foreach( $p in $props )
{
# write-verbose (invoke-expression "`$File.$($p.Name)")
$doc.Add( $p.Name, (invoke-expression "`$File.$($p.Name)") )
}
Friday, May 14, 2010
Enumerating Powershell NoteProperties
I recently was asked to stuff a custom PSObject into a bunch of key value pairs, so I thought I'd put it here. Is there a better way?
Labels:
hth,
powershell
I Want an Online-persona Manager
There's been a lot of hubbub about Facebook and its changing privacy settings. The short version is that they are changing them to the advantage of people who want to make a buck out of you and your friends. It didn't start out that way, and the change has people in a bit of an uproar.
Thing is, Facebook does serve a valuable function - otherwise there would be nothing to exploit. An easy way to keep a business account, and a personal account. Many people use LinkedIn (for professional contacts) and Facebook (for personal) in this manner, including myself.
What the Facebook uproar is making clear is that people value the partitions they build into their lives, and want those partitions maintained online. Another thing that is clear is that as users, we can be sure that policies will change, and we won't like some of those changes.
I don't want to quit Facebook. I like Facebook, for what it is. I don't begrudge Zuckerberg a few bucks off of me, as long as he provides a service I want to use.
What I want is an easier way to manage my profiles, so that I not only have control over what's published, and where, and I want it to be easy.
I want to maintain my own profiles in a centralized location - my hard drive, my backup.
I want to write something once, and then choose, with high granularity, where it will be published.
I want it to be universal, and work with damn near everything.
I want it to be simple, with one interface, like Pidgin does for IM.
I want it to be scriptable, because by now I'm just being greedy :)
I don't want project Diaspora. I'm happy for the kids, and I wish them well, but all they promise is that I'll either have to fire up a server for myself, or I'll have to trust someone else. Again.
I trust my laptop. I trust my mobile phone (sort of). I trust my thumb drive. I trust TrueCrypt. It is my data, and I should control it.
There's a reason businesses try to find out so much about us: it has value. Google has the luxury to walk away from the extra revenue; they're getting enough.
Interestingly enough, Microsoft has an initiative that addresses some of the problem. Called U-Prove, it is BSD-licensed to help drive adoption. It primarily deals with managing both identity and authorization in financial transactions - I don't know if it could be adapted to social sites. This Ars article goes into greater depth.
I dinked around with building something like this on my own, but honestly, it looks like a bit more work than I can tackle right now. So, if there's somebody out there that thinks is a good idea, and has the wherewithal to pull it off, please steal this idea - I'll be one of your early adopters, I promise.
Update: I came up with another way to describe it while discussing this privately (Hi, Tracey!):
I've got six accounts in Outlook right now, all pointing to different places. My personal domains don't know about my google addresses, and heck, my google addresses don't even "know" about one another. (Reading the Spam folders for each one is an education in targeted advertising.) I want the same thing, only for the various social networks.
Thing is, Facebook does serve a valuable function - otherwise there would be nothing to exploit. An easy way to keep a business account, and a personal account. Many people use LinkedIn (for professional contacts) and Facebook (for personal) in this manner, including myself.
What the Facebook uproar is making clear is that people value the partitions they build into their lives, and want those partitions maintained online. Another thing that is clear is that as users, we can be sure that policies will change, and we won't like some of those changes.
I don't want to quit Facebook. I like Facebook, for what it is. I don't begrudge Zuckerberg a few bucks off of me, as long as he provides a service I want to use.
What I want is an easier way to manage my profiles, so that I not only have control over what's published, and where, and I want it to be easy.
I want to maintain my own profiles in a centralized location - my hard drive, my backup.
I want to write something once, and then choose, with high granularity, where it will be published.
I want it to be universal, and work with damn near everything.
I want it to be simple, with one interface, like Pidgin does for IM.
I want it to be scriptable, because by now I'm just being greedy :)
I don't want project Diaspora. I'm happy for the kids, and I wish them well, but all they promise is that I'll either have to fire up a server for myself, or I'll have to trust someone else. Again.
I trust my laptop. I trust my mobile phone (sort of). I trust my thumb drive. I trust TrueCrypt. It is my data, and I should control it.
There's a reason businesses try to find out so much about us: it has value. Google has the luxury to walk away from the extra revenue; they're getting enough.
Interestingly enough, Microsoft has an initiative that addresses some of the problem. Called U-Prove, it is BSD-licensed to help drive adoption. It primarily deals with managing both identity and authorization in financial transactions - I don't know if it could be adapted to social sites. This Ars article goes into greater depth.
I dinked around with building something like this on my own, but honestly, it looks like a bit more work than I can tackle right now. So, if there's somebody out there that thinks is a good idea, and has the wherewithal to pull it off, please steal this idea - I'll be one of your early adopters, I promise.
Update: I came up with another way to describe it while discussing this privately (Hi, Tracey!):
I've got six accounts in Outlook right now, all pointing to different places. My personal domains don't know about my google addresses, and heck, my google addresses don't even "know" about one another. (Reading the Spam folders for each one is an education in targeted advertising.) I want the same thing, only for the various social networks.
Labels:
babble
Tuesday, May 11, 2010
Powershell grep'ing
I've been asked about searching and replacing in files a few times, so I thought I'd put an example up here. This is a way to do it - and you'll almost certainly want to change it around to better suit your scenario.
cd C:\Users\michael.DOMAIN\Workspace\Powershell
function pgrep
{
Param (
[string]
[parameter(mandatory=$true)]
$Like,
[bool]
$Recurse = $false,
[string]
$BasePath
)
Process {
if( -not $BasePath )
{
$BasePath = $PWD
}
# there's gotta be a slicker way
$recurse_string = ""
if( $Recurse )
{
$recurse_string = "-Recurse"
}
Invoke-Expression "Get-ChildItem -Path $BasePath $recurse_string" |
where {$_.PSIsContainer -eq $false } |
foreach {
$file = $_
# $file.FullName
# Get-Content -Path $file.FullName | where { $_ -eq "MachineName" }
if( Get-Content -Path $file.FullName | where { $_ -like $Like } )
{
$file
}
}
}
}
function preplace
{
Param (
[string]
$Path,
[string]
$From,
[string]
$To
)
Process {
$fi = New-Object -TypeName System.IO.FileInfo -ArgumentList $Path
$tmpfile = "$($fi.DirectoryName)\$($fi.Name).tmp"
Remove-Item -Path $tmpfile -ErrorAction SilentlyContinue
Get-Content $Path |
foreach {
$line = $_
$line.Replace( $From, $To )
} |
Add-Content -Path $tmpfile
Remove-Item -Path $Path -ErrorAction SilentlyContinue
Rename-Item -Path $tmpfile $Path
}
}
pgrep -Like "*MachineName*" -BasePath C:\Users\michael.DOMAIN\Workspace\Powershell |
foreach {
$fi = $_
Write-Host "updating $($fi.FullName)"
preplace -Path $fi.FullName -From "MachineName" -To "MachineFoo"
}
Labels:
hth,
powershell
Sunday, May 2, 2010
Getting Command Line Parameters Using Powershell
I'm just going to leave this here...
(gwmi win32_process -filter "name='powershell.exe'").commandLine
Labels:
hth,
powershell
Subscribe to:
Posts (Atom)