Quantcast
Channel: PowerShell.org » All Posts
Viewing all 13067 articles
Browse latest View live

Reply To: DSC + GIT

$
0
0

I have my DSC script, resources and configs in GIT. and use Jenkins to run the builds directly from GIT.


Reply To: Selling DSC

$
0
0

DSC configuration and text and can be stored in version control.
SCCM stores configuration in a database, there is no version control.

I expect newer version of system center will leverage DSC.

Reply To: DSC issue with Windows Features when reboot is needed

$
0
0

The November update to 2012r2 adds the continue on reboot option. prior to that it's reboot and wait for the timer to kick off the next consistency check.

Reply To: Triggered Job and FileSystemWatcher – combo not working

$
0
0

$CreatedAction is essentially a function that processes the file, puts output to a log, and a few other fairly basic things. Its within the script file.

"If you launch the script manually, then the $CreatedAction works, but if your startup job launches it then it doesn't work?"

This is correct. Its a bit bizarre to me.

Do you have run with highest privileges enabled in the job?

Yes.

Are your running the job as SYSTEM

Yes

and does system have access to do $CreatedAction?

I had not considered this and do not know the answer. $CreatedAction exists within the script that is running and I took for granted that in fact is was accessible by whatever needed it. I am not at all sure how to check access to this as I am not sure what is accessing it.

Small snippit:

"PowerShell Script run for date: $($now_date) " | Out-File -FilePath $powershell_log_file -Append

# This block of code runs when the event is heard. IE – a file placed in the directory
$CreatedAction =
{

"In created action function " | Out-File -FilePath $powershell_log_file -Append

## many more lines of code not shown.
……
}

This is code cut and pasted. First line is output to the log file on triggered start. The line within the $CreatedAction code block does NOT output to the log file, when a triggered start is used. When run manually that line is output and the rest of the code block (not shown) executes. Somehow, whatever mechanism that runs the $CreatedAction code block is not running it.

Hopefully this is more clear.

Reply To: Triggered Job and FileSystemWatcher – combo not working

$
0
0

It's tough to troublshoot with little snippets of code. The reference to $powershell_log_file, for instance, could be pointing to a network share that SYSTEM (the computer account) does not have access to. Another troubleshooting step, kill the watcher or script, change the context of the startup job to run as you and restart the server (or manually run the task). Does the script work? If so, my guess is there is something in your $CreatedAction block that SYSTEM can't do. You could add a line to create another log locally somewhere place it at the beginning of your $CreatedAction block to see if it's actually triggering.

Get-FSRMQuota

$
0
0

I am having an issue that I hope someone here can clue me in on. When I try to run the following script it does not work:
$Qpath = $QPath = '"'+'D:\DATA\USERS\'+$User+'"'
$QSize = Get-FSRMQuota -Path $QPath

The error message is:
Get-FSRMQuota : 0x80045306, The specified path is invalid.
At line:9 char:10
+ $QSize = Get-FSRMQuota -Path $QPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_FSRMQuota:Root/Microsoft/…
/MSFT_FSRMQuota) [Get-FsrmQuota], CimException
+ FullyQualifiedErrorId : HRESULT 0x80045306,Get-FsrmQuota

The odd thing if I take the contents of $QPath and paste them in place of $QPath it then works.

Any ideas of what I'm doing wrong? All I am trying to do is to get user quotas, user by user.

Reply To: Get-FSRMQuota

$
0
0

I'm having some trouble resolving all the quotes.

$QPath = $QPath =

Also doesn't make sense to me. What's the goal there?

$QPath = "D:\DATA\USERS\$User"

Is that sufficient? PowerShell will fill-in variable names inside double quotes. I don't think you need all that concatenating.

Don Jones
Curriculum Director for IT Pro Content, Pluralsight.com

Reply To: Can you use "try..catch" more than once ?

$
0
0

Well it all depends on how you handle the exception. In my example I use Write-Error which produces the fancy red text. You could do Write-Warning instead, or something completely different. That's why it's called exception handling. You handle exceptions however you like.


Reply To: Register-schedulejob for exchange 2010

$
0
0

hello Don,

Thank you for your answer.

I am running the task with a domain admin account. And if I run the same command directly from powershell it works.

any ideas.

thanks.

patrick

Reply To: csv powershell manipulation

$
0
0

I like string format:

$upn = "{0}@{1}" -f $column.Primaryemail ,$column.primarydomain

You don't need double quotes or any nonsense typically when you build the string and I find that it just always works.

Reply To: DSC issue with Windows Features when reboot is needed

$
0
0

Hi guys,
thank you for response! I really appreciate your assistance!

Reply To: Register-schedulejob for exchange 2010

$
0
0

I also tried to run the schedule task directly on the exchange server and it doesn't work.

Reply To: Register-schedulejob for exchange 2010

$
0
0

I didn't see the domain account on the Register-ScheduledJob command, sorry. That's something you might double-check.

There could be several things wrong. Permissions come to mind first. It's also possible something in the command is expecting a full user profile to be loaded, which doesn't happen when Task Scheduler runs the command. Are you running the scheduled task with the *same* domain account that you use to test? Is the scheduled task running on the same machine you test on? Can you create a scheduled task that simply runs { Get-Command Get-Mailbox } and see if that succeeds (if it doesn't, then Task Scheduler is having problems finding the Get-Mailbox command, which is your problem). It's a little hard to really troubleshoot when I'm not in your environment with you, but in general I try to think of all the differences between what I'm running, and what Task Scheduler does, and then try and test each of those things individually.

Don Jones
Curriculum Director for IT Pro Content, Pluralsight.com

Reply To: Register-schedulejob for exchange 2010

$
0
0

If you look at the scheduled task, in what context is the task running?

security

Attachments:
You must be logged in to view attached files.

Reply To: Can you use "try..catch" more than once ?

$
0
0

Arrrr….i see. Thanks. I'm currently going through Jeff Hicks brilliant videos on the Pluralsight website. But all this is great to know.


Reply To: Invoking Registry UninstallString

$
0
0

So continuing from above.
I believe I'll need to take the "UninstallString" value and plug it in on the fly into the $uninst variable for this to work on any system I'd like to use it on.
As the number that precedes "xxxxxxxxx.sloobapp.somewebsite.com" is a randomly generated integer that can be any integer 0-9 of any length.

I'm kind of at a loss how to do this, originally I was thinking I'd have to utilize a regular expression to account for the unique integer string preceding the webclient.

Thoughts or Suggestions?

Reply To: csv powershell manipulation

$
0
0

I actually updated it with the UPN now coming from the excel
$c= @()
$c = Import-Csv C:\Temp\users.v1-testlogins.csv -Delimiter ','

foreach ($column in $c)

{
$upn = $column.UserPrincipalName
$proxy = $User.ProxyAddresses -split ';'
new-mailbox -name "$($column.Firstname) $($column.lastname)" -Password (ConvertTo-SecureString $column.password -AsPlainText -force) -UserPrincipalName $upn -FirstName $column.Firstname -LastName $column.Lastname -PrimarySmtpAddress $column.PrimarySmtpAddress -OrganizationalUnit $OU -Database $column.Database
Set-Mailbox -Identity $SAM -EmailAddresses @{add= $proxy}
Add-ADGroupMember -Identity 'omited' -Members $SAM
}

Rob, don't really understand the {0} and {1} with -f, can you explain.

Also running through the syntax of above it seems to Set-Mailbox and Add-ADGroupMember the first one running through the foreach but misses the rest, sorry I'm not asking to make it work but try to understand how the foreach works

Reply To: csv powershell manipulation

$
0
0

Ah no problem now Rob I understand it, pretty cool and now in use!

Just going to figure out this weekend how to parse more then one command through a foreach, thanks guys for all your help!

Reply To: Invoking Registry UninstallString

$
0
0

I was wondering about this earlier when I looked at it but you said you had it working. You connect to registry, find the uninstall string and then use a manual uninstall string. Take a look at this and see if you understand the logic:

function Get-InstalledApps {
param()
    begin{}
    process{
        $apps = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* |
                Select DisplayName, 
                DisplayVersion, 
                UnInstallString,
                InstallDate,
                @{Name="VERSION_MAJOR";Expression={($_.DisplayVersion.Split("."))[0]}},
                @{Name="VERSION_MINOR";Expression={($_.DisplayVersion.Split("."))[1]}},
                @{Name="VERSION_REVISION";Expression={($_.DisplayVersion.Split("."))[2]}},
                @{Name="VERSION_BUILD";Expression={($_.DisplayVersion.Split("."))[3]}}, 
                @{Name="GUID";Expression={$_.PSChildName}},
                @{Name="AppArchitecture";Expression={"86"}}
        # If it is a 64-bit box, then also include the Wow6432Node
        if((Get-WmiObject Win32_Processor).AddressWidth -eq 64){
            $apps += Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | 
                     Select DisplayName,
                     DisplayVersion, 
                     UnInstallString,
                     InstallDate, 
                     @{Name="VERSION_MAJOR";Expression={($_.DisplayVersion.Split("."))[0]}},
                     @{Name="VERSION_MINOR";Expression={($_.DisplayVersion.Split("."))[1]}},
                     @{Name="VERSION_REVISION";Expression={($_.DisplayVersion.Split("."))[2]}},
                     @{Name="VERSION_BUILD";Expression={($_.DisplayVersion.Split("."))[3]}}, 
                     @{Name="GUID";Expression={$_.PSChildName}}, 
                     @{Name="AppArchitecture";Expression={"64"}}
        }
 
        $apps | Where{ !([string]::IsNullOrEmpty($_.DisplayName)) }
    }
    end{}
}
 
# Get all 32\64 bit applications
$installedApps = Get-InstalledApps
# Find any application with SLOOBAPP in the name
$silverLight = $installedApps | Where-Object {$_.DisplayName -match "SLOOBAPP"}
 
#If an application was found (variable not null)…
if ($silverLight) {
    foreach ($application in $installedApps) {
        #if the uninstall string is not null…
        If ($application.UninstallString){
            #Here you are specifying (x86) only, so this would fail if there were a 64-bit Silverlight installation
            #You should use similar logic I'm using in the function above to see if it's a 64-bit machine or I'm adding
            #an AppArchitecture param, so you could do if ($application.AppArchitecture -eq 32){"Set location for 32}else{Set Location for 64}
            Set-Location -Path "c:\Program Files (x86)\Microsoft Silverlight\5.1.30514.0"
            #Rather than use a manual string (e.g. $uninst, you would just reference
            "Running command: {0} from {1}" -f $application.UninstallString, (Get-Location)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $application.UninstallString -wait
        }
        else {
            "There is not uninstall string for {0}" -f $application.DisplayName
        } #if UnInstallString
    } #for each application
}
else {
    "Silverlight is not installed."
} #if $silverlight

Reply To: Managing .mof files. How do you avoid making multiple .mofs for the same node?

Viewing all 13067 articles
Browse latest View live