PowerShell scripts and Azure

Please forward if this is not the correct forum.
I'm trying to create Azure Powershell scripts that can be executed on a scheduled basis, however an authentication popup is always displayed before the commands can be executed. I've tried importing my publishersettings file, specifying the management certificate,
etc.
Can someone please paste a sample script below to simple run start-azurevm which includes commands to authenticate without user interaction?
Also include where the certificates, ... come from.
Thank you,
David
David Downing... If this answers your question, please Mark as the Answer. If this post is helpful, please vote as helpful.

Hi,
If you are using in an automation script and want to avoid any pop up window, please try the following snippet.
$userName = "<your organizational account user name>"
$securePassword = ConvertTo-SecureString -String "<your organizational account password>" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
Add-AzureAccount -Credential $cred
If I misunderstand, please feel free to let me know.
Best Regards,
Jambor
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Trigger custom powershell scripts using azure xplat-cli module

    I am using ansible hosted on linux to manage both Linux and windows VMs hosted on azure, and use azure xplat-cli commandline to create VMs. When i create windows server 2008, I need to trigger few startup scripts so that those are preconfigured while windows
    server is up. I was able to install CustomScript extension using below command
    # azure vm extension set <vmname> <publisher> <version>
    I have uploaded my scripts to azure blob storage account, and i need to trigger scripts using the extension, and i don't find any proper documentation (documentation was only for powershell). Can you please help

    Hi,
    Based on my experience, you can configure extensions via the Azure Preview Portal. Besides, the article below ay be helpful to you:
    Automate Linux VM Customization Tasks Using CustomScript Extension
    In addition, you are correct, there is no official document for that. You can ask a script in the Azure Script center:
    http://azure.microsoft.com/en-us/documentation/scripts/
    Best regards,
    Susie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • SCCM 2012 application run Powershell script and return codes

    Hi,
    I created an new application (imported as MSI) in SCCM 2012R2. After import I changed the deployment type installation program to run a Powershell script: powershell.exe -ExecutionPolicy Unrestricted -File "Install FactSet 2013 5I.ps1
    My goal is to close some processes before installing the MSI. This works. But on a failure the application program also return code 0 (AppEnforce.log). Is it possible to pass the MSI return codes to SCCM.
    Maybe anyone had the same or idea's to solve this? Thanks in advance.
    Regards,
    Peter
    Powershell script code:
    $ExitCode=0
    Function
    Stop-RunningApplication{
    Param(
    [parameter(Mandatory
    =$true)]
    [string]$ProcessName#
    Specify process names separated by commas
    # Split multiple processes on a comma and join with the regex operator '|' to perform "or" match against
    multiple applications
    $processName=$processName-split(",")
    -join("|")
    $process=Get-Process|Where{
    $_.ProcessName
    -match$processName}
    |Stop-Process-Force
    #Stop running processes
    Stop-RunningApplication
    -ProcessName"excel,outlook,fdsw32,marquee,POWERPNT,WINWORD"
    #Install FactSet 2013 5I
    $ExitCode
    =(Start-Process".\FactSet_Setup_2013_5I_x644.msi"'/qn
    FACTSET_CLOSE_PROCESSES=1 /l*v C:\Temp\InstFac20135I.log'-Wait-Passthru).ExitCode
    Environment]::Exit($ExitCode)
    Peter vd Bosch

    It's really hard to tell from the code above because of the way it's listed, but are sure that even executes? I see at least one stray curly brace and a stray square bracket.
    For the Start-Process cmdlet, have you tried without the -passthru parameter?
    Also, using the actual parameters will make the code much more readable instead of relying on position.
    Jason | http://blog.configmgrftw.com | @jasonsandys

  • Installer launching command prompt that should run a powershell script and remain open

    I am using the Microsoft Visual Studio Installer Projects extension for VS 2013. This installer is designed to place a windows app in a directory and then launch a powershell script to prompt the user to sideload the application. From what I read online,
    you can make a windows console application and then add that .exe under the install custom actions to have the exe run after the installation is done. My installer is running the executable, but not in the way I want it to. This is the code that the console
    application has:
    static void Main(string[] args)
    Process.Start(@"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", @"-ExecutionPolicy bypass -NoExit -File Application\Add-AppDevPackage.ps1");
    One key thing to note here is the -NoExit. I want the prompt to remain open. If I run this console application directly, the powershell console does indeed stay open. You can see here where I have added the .exe as part of the install custom action.
    One additional thing to note is when I looked at the exe in the directory after the install, it is different than the one generated when I compile the console application project. I wouldn't know why the installer is physically changing the binary when I
    expect it to just copy the output from that compiled project/copy that file.
    If anyone has any additional input on how to make this process easier to have an installer (.msi) to place my windows app in a directory and run a powershell script to prompt the user to sideload it, then I welcome that too.

    Hello,
    I am afraid this issue is beyond the scope of our support.
    The current forum you posted to is used to discuss general issues about developing applications for Windows.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Ping all the servers into SP farm using powershell script and send email only if any of them failed to ping.

    Hi,
    i am trying to have such kind of functionality, so that if any servers in sharepoint farm failed then it will send notification email to specific user that server is not able to ping or failed. Right now following script is working but it sending mail either
    servers are all running or dead. But i would like to send email only if any of the server failed to ping. what i need to modify following code to work.
    Thanks in advanced
    #### Provide the computer name in $computername variable 
    $ServerName = "localhost","Dc-XX"  
    $smtp = "ExchChange" 
    $to = "[email protected]
    $from = "[email protected]
    $sub = " Server Status" 
    $body = @" 
    ##### Script Starts Here ######   
     foreach ($Server in $ServerName) { 
                        if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {  
                            $body += write-output "$Server is alive and Pinging `n"  
                                } else { $body += Write-output "$Server seems dead not pinging `n"  
    $body 
    send-MailMessage -SmtpServer $smtp -To $to -Subject $sub -Body $body  -From $from   

    you need to put a check on the send-mailmessage if no ping fails then exit else send the email with message.
    also try this script, performing the the same thing but more granular way
    http://gallery.technet.microsoft.com/scriptcenter/d0670079-6158-4dc5-a9da-b261c70e4b7d#content
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Get all parameters pass to a powershell script and store it in a variable

    Hi,
    Test.ps1 A B C D E F
    1. How may I get how many parameters was pass to the commandline?
    2. I would like storing A B C D E F in a variable and store Test.ps1 $arguments in VariableWithCommandLine.
    New-Item -path $path -Name test2.ps1 -type file -Value "VariableWithCommandLine"
    Thanks,

    Why this is not working?
    [CmdletBinding()]
    Param (
     [Parameter(Mandatory=$True)]   
     [ValidateSet('Install','Repair','Uninstall', 'MAJ')]  
     [string]$DeploymentType = 'Install',
     [Parameter(Mandatory=$false)]   #Paramètre obligatoire? $True $False
     [ValidateSet('Interactive','Silent','NonInteractive')] #Silent = No dialogs (progress and balloon tip notifications are supressed)
     #NonInteractive = Very silent, i.e. no blocking apps. Noninteractive mode is automatically set if an SCCM task sequence or session 0 is detected.
     [string]$DeployMode = 'Interactive'
    $args

  • How to insert the file name to the start and the end of a SQL file by a powershell script

    I just began to learn powershell script and I have a problem that I cannot figure out. I have a lot of .sql files. I need to insert its file name to the beginning of the file (After USE statement) and the end of the file (before the last END statement). Is
    there anybody knowing how to do this?
    Thanks so much
    Regards

    Actually, I want to add a insert SQL statement to the beginning of the file and the end of the file. Only the file name is a variable and different among
    different files. All the other sql statements are the same and can be hard coded. Hopefully it helps –
    The problem I think is that I want to add the same thing (except the file name) to hundreds of sql files and only the file name is different. I do not want
    to add it manually and want to use a script to add it – 

  • SSMS and Powershell Script Generation issue

    Tested in 2008 R2, 2012 and 2014 all on the latest SP + CU
    When  I generate as script from SSMS for the database tables via Generate Scripts there is an issue, when you generate the script for the database objects and there is data in the table with the options set to false for "Constraints and Defaults.
    Scripting defaults = false (This always outputs when there is data, I think this is where the bug is)
    Scripting Check Constraints = False ( had this also set, but didn't make any difference if it was on or off)
    This is my test tables, table A has data and Table B has "no data".
    Issue also exists in Powershell using SMO to generate a script for the tables
    I don't want to output the Default values in the script? But if there is data then it will output the defaults as shown below.
    How do I fix?
    This is the output:
    USE [tktest1]
    GO
    /****** Object: Table [dbo].[TableA] Script Date: 2015-04-18 9:16:48 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[TableA](
    [TableID] [int] IDENTITY(1,1) NOT NULL,
    [Col1] [varchar](50) NULL,
    [Col2] [varchar](50) NULL CONSTRAINT [DF_TableA_Col2] DEFAULT ('Y'),
    CONSTRAINT [PK_TableA] PRIMARY KEY CLUSTERED
    [TableID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    /****** Object: Table [dbo].[TableB] Script Date: 2015-04-18 9:16:48 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[TableB](
    [TableID] [int] IDENTITY(1,1) NOT NULL,
    [Col1] [varchar](50) NULL,
    [Col2] [varchar](50) NULL,
    CONSTRAINT [PK_TableB] PRIMARY KEY CLUSTERED
    [TableID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    This is using the Script table as from SSMS:
    Table A
    USE [tktest1]
    GO
    /****** Object: Table [dbo].[TableA] Script Date: 2015-04-18 10:07:41 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[TableA](
    [TableID] [int] IDENTITY(1,1) NOT NULL,
    [Col1] [varchar](50) NULL,
    [Col2] [varchar](50) NULL CONSTRAINT [DF_TableA_Col2] DEFAULT ('Y'),
    CONSTRAINT [PK_TableA] PRIMARY KEY CLUSTERED
    [TableID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    Table B
    USE [tktest1]
    GO
    /****** Object: Table [dbo].[TableB] Script Date: 2015-04-18 9:23:02 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[TableB](
    [TableID] [int] IDENTITY(1,1) NOT NULL,
    [Col1] [varchar](50) NULL,
    [Col2] [varchar](50) NULL,
    CONSTRAINT [PK_TableB] PRIMARY KEY CLUSTERED
    [TableID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    ALTER TABLE [dbo].[TableB] ADD CONSTRAINT [DF_TableB_Col2] DEFAULT ('Y') FOR [Col2]
    GO

    I have tried this on 3 different box's. 1 Production and 2 dev box's.
    Production box has 2008 R2 SP3 Feature pack SharedManagementObjects.msi . remote client has 2008 R2 SP3 Feature pack SharedManagementObjects.msi and 2012 SP2+CU5 + S2 Feature pack SharedManagementObjects.msi.  the client is where I run the powershell
    script and the SSMS script.
    This version of SMO is 11.2.5058.0
    Dev box 1 has 2008 R2 SP3 Feature pack SharedManagementObjects.msi and 2012 SP2+CU5 + S2 Feature pack SharedManagementObjects.msi
    On this box the version of SMO is 11.2.5058.0.
    Dev box 1 has 2008 R2 SP3 Feature pack SharedManagementObjects.msi , 2014 Feature pack SharedManagementObjects.msi
    Just installed the SMO for 2014 Version 12.0.2000.8. and retested below.
    for the Create default method I can not use as the Production system code would all need to be change.  and this won't happen anytime soon.  Lots of database and lots of tables in the database.  Good to know I have options.
    Table A and Table B are the same.  Both have the defaults set on the table at create time.
    Only diff is one has data and one does not have data.
    Here is the Create script I used for Table A and Table B.
    1st test:  No rows in table A or B, Generate script with script defaults set to false.  Script does not generate defaults.
    2nd test: Add one row to Table A, Generate script with script defaults set to false. script generates defaults in the script.
    CREATE TABLE [dbo].[TableA](
    [TableID] [int] IDENTITY(1,1) NOT NULL,
    [Col1] [varchar](50) NULL,
    [Col2] [varchar](50) NULL CONSTRAINT [DF_TableA_Col2] DEFAULT ('Y'),
    CONSTRAINT [PK_TableA] PRIMARY KEY CLUSTERED
    [TableID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    CREATE TABLE [dbo].[TableB](
    [TableID] [int] IDENTITY(1,1) NOT NULL,
    [Col1] [varchar](50) NULL,
    [Col2] [varchar](50) NULL CONSTRAINT [DF_TableB_Col2] DEFAULT ('Y'),
    CONSTRAINT [PK_TableB] PRIMARY KEY CLUSTERED
    [TableID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    ---For SSMS when you script table as Create To> for Table A and Table B.
    Why does table A with data add the default Constraint in the output and Table B with no data adds the Alter table Add constraint at the end?
    To me it should have created both the same.(as I shown above in the first post ,using the Script table as from SSMS: Table A and Table B)
    I see the issue on 3 different box's before and after upgrading SMO on all of them.
    here is a very similar issue for smo in powershell(https://connect.microsoft.com/SQLServer/feedback/details/745566/smo-2012-disregards-default-constraint)
    Thanks
    Trevor

  • Using Echo Command in PowerShell Script for Configuration Item

    Hello All,
    Before you tell me to post my PowerShell question to the PowerShell Forum, please know that the PowerShell portion of my task works just fine. It is the SCCM portion of my task that keeps failing, so that is why I am here. To give some background...
    There are two servers in our SCCM test environment. Both the SCCM server and SQL DB server are 2012, patched and updated.
    Test servers in my Device Collection being used for running Baselines and Reports against are 2008R2 and 2012, patched and updated.
    I have created a Configuration Item that checks to see if the FTP Server Role Feature has been installed on a 2008 or 2012 server. To do the check, I am using the following PowerShell script:
    (get-windowsfeature -Name Web-Ftp-Server).Installed
    When I log into my 2008R2 and 2012 test servers, and run this command directly on the server, it will return a "True" if the FTP Server Role Feature is installed on either server, and a "False" if it is not installed. Basically,
    it works as advertised.
    When I setup my Configuration Item and then deploy my Baseline, or run a report against my device collection of test servers, SCCM will return a correct response (True or False) for the 2012 test server, but throws the following error for the 2008R2
    server:
    0x87df00329 application requirement evaluation or detection failed
    Google searches for this have not been very helpful.
    Now, when I created the Configuration Item and referenced PowerShell, the configuration screen has the following note:
    "Specify the script to find and return the value to be assessed for compliance on client devices. Use the echo command to return the script value to Configuration Manager."
    Since I did not include an echo command in my PowerShell script above, I figured that was my problem, so I did the following:
    Logging onto both of my test servers (2008R2 & 2012) I was able to successfully run the following PowerShell commands and get the expected responses of True or False:
    (get-windowsfeature -Name Web-Ftp-Server).Installed | echo
    (get-windowsfeature -Name Web-Ftp-Server).Installed | write-output (http://technet.microsoft.com/en-us/library/hh849921.aspx)
    (get-windowsfeature -Name Web-Ftp-Server).Installed | write-host (http://technet.microsoft.com/en-us/library/ee177031.aspx)
    However, when I use any of these PowerShell commands in my Configuration Item, NEITHER of my test servers returns a response to the SCCM server.
    When I check the report, both servers show as "Unknown" and when I click on the number 2 (as in 2 servers unknown), the following report page (List of unknown assets for a configuration baseline) has absolutely no data/information at all.
    So...I am at a loss.
    SCCM tells me to use an echo command to return a script value to Configuration Manager. The PowerShell scripts above, with the various echo related commands, work just fine on the servers themselves, but they return no information when run via SCCM.
    What am I missing?
    Any help will be appreciated.
    Thanks in advance for your time.

    Sorry for my ignorance, but I don't understand. (I forgot to mention that I am new at both PowerShell and SCCM.)
    After I change the PowerShell script to add the echo/write-output/write-host cmdlet, I open the ConFig Item and "Clear" the PowerShell script and then re-add it. When I do that, it correctly shows the change in the ConFig Item.
    Next I open the Baseline, then open the ConFig Item within the Baseline to make sure the change is reflected there as well, which it is.
    I then deploy the Baseline to my Device Collection. After that, I run a report against the Baseline and Device Collection and it returns the "Unknown" result.
    If I open the PowerShell script and remove the echo/write-output/write-host cmdlet, then go through the rest of the process of updating and reporting, the result it returns changes, showing one server in compliance and the other server out of compliance,
    which leads me to think that all changes have taken correctly.
    Does that sound right? If I manually deploy the Baseline, is that the same as the client retrieving policies from the management point?
    Sorry to be so thick but I'm learning as I go.
    Thanks again for your help.

  • Error with SMLets in an Orchestrator called PowerShell Scripts

    Hi!
    This is likely so simple I am overlooking the problem but...
    I have a "Run .Net Script" activity in an Orchestrator 2012 SP1 Runbook.  It calls SMLets.  The issue is it runs in the PowerShell ISE on the Runbook server without issue.  It runs in the Runbook Tester just fine.  But if I
    call the runbook with the PowerShell script, it errors out on the first call the a SMLets provide cmdlet.
    A Few Detail:
    We loaded the latest SMLets from CodePlex.  We can use the cmdlets in both the 32-bit and 64-bit environments.
    The very first line of the PowerShell script is: Import-Module SMLets
    The first SM cmdlet is: $class = Get-SCSMClass System.WorkItem.Activity.ReviewActivity$
    The Runbook Containing the PowerShell Script:
    And lastly, the Event of the error thrown:
    In trying to make this work we have tried to run the script remotely on the SCSM server (New-PSSession and Invoke-Command).  Failures due to rights on the SCSM server. 
    My opinion is the issue is a rights issue but we cannot find the difference between any of the accounts testing/debugging and the Orchestrator Runbook Service account.  I can run the PowerShell and the Runbook Tester when logged on as the
    Orchestrator Runbook Service account.  It works until I have to call the runbook with the PowerShell Activity.  It just like my Account.  We've even set the account on the security tab of the Invoke Runbook Activity.
    Is there something I've overlooked?  Something in the install of the SMLets, maybe? A clue?  Help?
    If nothing else, thank you for letting me voice my issue onto the 'Net.  Maybe someone else has been down this road and can tell me where the off-ramp is.  ;-)
    Ray Watters,
    Chicago, IL

    Hi,
    also make sure that your PS scriptruns with Windows PowerShell (x86) (32bit)
    http://www.sc-orchestrator.eu/index.php/scoblog/64-using-64bit-powershell-cmdlets-in-the-run-net-script-activity-from-orchestrator
    or with PowerShell V2
    http://www.sc-orchestrator.eu/index.php/scoblog/102-running-powershell-30-with-the-run-net-script-activity
    Regards,
    Stefan
    www.sc-orchestrator.eu ,
    Blog sc-orchestrator.eu

  • Piping script line in a powershell script

    Hi,
    I would like piping informations in a powershell script and getting this:
    If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    $arguments = "& '" + $myinvocation.mycommand.definition + "'"
    Start-Process powershell -Verb runAs -ArgumentList $arguments
    Break
    [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent # Emplacement du script
    powershell.exe -executionpolicy bypass -File $scriptDirectory\Vcredist2005_Frv1.ps1 install
    =====================================
    ======================================
    My script is looking this:
    $var_InterventionManuelle ="c:\temp"
    $var_FichierLancementManuelle = "install_Man.ps1"
    $var_EmplacementFichierLancementManuelle ="c:\temp\install_Man.ps1"
    New-Item -path $var_InterventionManuelle -Name $var_FichierLancementManuelle -type file
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`nIf (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))"
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`n{"
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`n$arguments = ""&" '" + $myinvocation.mycommand.definition + "'""
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`nStart-Process powershell -Verb runAs -ArgumentList $arguments"
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`nBreak"
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`n}"
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`n[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent"
    Add-Content -path $var_EmplacementFichierLancementManuelle -Value "`npowershell.exe -executionpolicy bypass -File $scriptDirectory\$var_Scriptactuel install"
    It is failing on the first add-content. Where am I wrong? Is it an easier way to do this?
    Thanks,
    François

    Hi,
    If all you're trying to do is write all of that to a file, you can do something like this:
    $text = @'
    If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    $arguments = "& '" + $myinvocation.mycommand.definition + "'"
    Start-Process powershell -Verb runAs -ArgumentList $arguments
    Break
    [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent # Emplacement du script
    powershell.exe -executionpolicy bypass -File $scriptDirectory\Vcredist2005_Frv1.ps1 install
    $text | Out-File .\script.ps1
    Here's some information about here-strings:
    http://technet.microsoft.com/en-us/library/ee692792.aspx
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • PowerShell scripts in Visual Studio

    Hello, 
    I'm getting started with PowerShell scripting and i was wondering if powershell script can be assigned to a visual studio button to do its function. 
    If so can someone please give me some examples or point me in the right direction? 
    Thanks in advance
    GeekzInside.

    Sounds good - thanks :) 
    Good luck.
    True searching:
    https://msdn.microsoft.com/en-us/library/76712d27.aspx?f=255&MSPPError=-2147217396
    \_(ツ)_/

  • New to Powershell Scripting

    Hey,
    New to PowerShell scripting and new to the forum.
    Have been given a task to populate the 'Company' field under 'Organization' in AD and would very mush appreciate some guidance.
    Don't want to manually populate the field and was wondering whether there is a simple script to add the 'Company' name.
    BigThack

    Hi Bill, thanks for the reply, however, have over 2000 users to go through and didn't want to did this manually.
    The nice part about using ADUC is that you can just multiselect all of those users and update the company attribute in one step.
    I honestly think this will be the easiest and quickest method of doing this if you're not comfortable with scripting.
    If you're using this as a reason to learn PowerShell though, both Fred and jrv have good suggestions.
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)
    A good tip, as it is nice to know that ADU&C allows simple bulk modifications like this.
    But likely the next task he will be assigned will not be as easily handled with ADU&C. My guess is that this task may involve populating each user's EmployeeID field. For that reason, among others, BigThack would be well advised to continue learning
    Powershell.
    And, in addition to the scripting guys forum, there is also the
    Powershell Forum.
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

  • Running a Powershell script via IIS on client machine

    Hello,
    I have a Powershell script that I want to serve to clients that will access my site.
    The script is simple - it will terminate Outlook and Communicator and restart in Cleanfreebusy mode.
    Researching this has noted that there is an IIS plugin that will allow the running of Powershell scripts?
    I would like to ask you, colleagues, is there a way I may be able to do this? That is to allow my clients run this Powershell script without downloading locally.
    Many many thanks,

    I have somewhat of a similar process, where I asked on the ASP.NET forums, as I needed my users of an Intranet site to be able to have a script run with the click of the button. I was told that it was not possible, as the browser is built to not allow stuff
    like this for security reasons.
    I haven't heard of a plugin so maybe there are other ways, but what I actually had to do, was create a batch file, and than on my webpage I added an IFrame
    <iframe id="myIframe" runat="server"></iframe>
    Than either in the html markup you can set the src attribute (I did mine in the code behind), to the directory where the file is at, so for instance \\myserver\fileishere
    Obviously the location needs to be shared and allow all users read/execute. This will display the file on the web page, and then the users, just double click it and it executes.
    You can possibly have a batch file that calls powershell and the script, but the script will need to be downloaded to the users machine, so it may be easier to find a batch equivallent of your powershell script and use DOS commands
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

  • How can I call or reference custom action assembly in powershell script?

    Hello
    I have added some custom action in document library settings. Now I want to use this custom action properties using powershell for some bulk operations. So for this I want to call this custom action assembly and set a reference in PowerShell script and then
    update custom action properties.
    Please let me know how can I do this?
    Avi

    If you also want to automate this than there is a CodePlex action that'll possibly come in handy for you.
    https://ilovesharepoint.codeplex.com/wikipage?title=Execute%20PowerShell%20Script%20Action&referringTitle=Workflow%20Actions%20for%20SharePoint%20Designer%202010
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

Maybe you are looking for

  • Field "Mat Slip" (MTSNR) of MB03 is empty after i run BAPI_GOODSMVT_CREATE

    Hello, I'm doing BAPI_GOODSMVT_CREATE for moviment '315'. After i run the BAPI, when i go to MB03, the field "Mat. Slip" is empty and does not appear on the screen! I'm using the following parameters: code= '04' ITEM: t_saida-matnr TO t_bapiitem-mate

  • Poor quality on slow motion!!! (pixelated)

    I would be soooooo grateful if someone could help me here! Okay, Ive been using final cut express for the past probably 5 months and had no problem but the other day when i went to edit a new video I noticed when i exported it any clips that had thei

  • Image stretched in Develop view

    Some images (portrait with metadata error "!") stretch to the width of the window when viewed in Develop Module. Is there something I can do to fix this?

  • Will photoshop elements 9 organizer transfer when I upgrade?

    Will my current photoshop elements 9 organizer transfer when I buy a monthly service with Adobe?

  • Color Labels in Photoshop

    Does anyone know if there is a way to change color labels WITHIN photoshop? i do NOT mean labelling a layer or group. I mean labelling a FILE within psd that can be read in Bridge/Lightroom. I know I can tag them there, but I would like to be able to