w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Is there a SCP alternative for PowerShell?
There is a handy little tool that comes with Putty called pscp.exe that will do this and can be called in powershell easily. Example below copies from windows to a CentOS box (logging in as the usercode "bill") and you use the -pw switch in pscp to pass in a password (otherwise the command window that is spawned will prompt for the Linux password): Start-Process 'C:Program Files (x86)PuTTYpscp.exe' -ArgumentList ("-scp -pw password C:Document.rtf bill@192.168.0.28:/home/bill/") PuTTY Secure Copy client Release 0.62 Usage: pscp [options] [user@]host:source target pscp [options] source [source...] [user@]host:target pscp [options] -ls [user@]host:filespec Options: -V print version information and exit -pgpfp print PGP key fingerprints and exit -p

Categories : Powershell

Powershell script running fine on Windows 8 but not on Windows 7
The error indicates you didn't correctly set the execution policy. Firstly, you have run Powershell as an administrator. To do this, right click on the Powershell icon in the start menu and click on "Run as Administrator". Next you have to run the following command in Powershell: Set-ExecutionPolicy RemoteSigned You will be prompted to allow the change. Type "Y" and press return. Finally, try running your script.

Categories : Powershell

Unable to connect to Windows Azure from Powershell Azure Powershell module
To see is there some result from Import-AzurePublishSettingsFile you can call: Get-AzureSubscription By default it select the default to current subscription. If you don't see any result then you don't import your subscription settings right. This Introduction to Windows Azure PowerShell also can help you.

Categories : Windows

Alternative to Windows Service
I think you might be able to use the Task Scheduler to start a program with administrator privileges. Here's a website demonstrating how to create a shortcut that runs with Administrative privileges with no UAC prompts, it uses the Task Scheduler as its way of launching the program. http://www.howtogeek.com/howto/windows-vista/create-administrator-mode-shortcuts-without-uac-prompts-in-windows-vista/ If you don't want to invoke it manually, you can still use the Task Scheduler's usual features to start the program automatically.

Categories : Windows

Windows Code-Signing process & alternative to MS signtool.exe?
There is kSign, and their blog also has an article about how to integrate with Inno Setup. It is not a complete replacement for signtool (i.e. it won't sign .cat and .sys files involved in signing driver packages) but it will will digitally sign EXE,DLL,COM,CAB and OCX files.

Categories : Misc

Open Source alternative to Windows Identity Foundation
WIF deals mostly with SAML tokens and WS-Federation (websites) based identity federation. For other alternatives (OAuth, OpenId) there are various frameworks. One of them is DotNetOpenAuth. If your solution will be SAML based, I wouldn't bother too much with anything but WIF, unless you have a good reason (e.g. you are not running on Windows).

Categories : Authentication

Alternative for file access in windows share files
The Samba suite provides windows file server functionality for unix systems. Also you might like to look at NFS. Even OCFS2 might be an alternative.

Categories : Linux

Better alternative to batch file for automatic Git-Pull on windows server
I don't recognize the situation that you would have to make special environment settings to make Git commands work. Are you sure you have it set up the right way? I usually recommend that developers to Install msysgit Install TortoiseGit. While installing TortoiseGit, they should choose OpenSSH (not TortoiseGitPLink). Run ssh-keygen.exe -C "firstname.lastname@domain.com" to generate keys in the $HOME.ssh folder Copy the public key in .sshid_rsa.pub to the Git server. OpenSSH does not require pageant.exe. After this setup, no extra environment settings are needed. (SSH_AGENT_PID and SSH_AUTH_SOCK variables are set up by the frameworks). git clone ssh://xxxx should work right away.

Categories : GIT

Using nano in expect scripts
Why don't you specify the commit message on the command line and avoid the editor? spawn sudo svn commit -m "this is my commit log message" e http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.commit.html If you do not supply a log message with your commit by using either the --file or --message option, svn will launch your editor for you to compose a commit message.

Categories : Svn

Run text editor with Groovy such as VIM or Nano
I think the VI solution fails because you no longer have a console (but you weren't very specific about this). I'm embarassed to say I don't know how to fix this on a Unix machine, on DOS I would use "command /c vi" to run it in a new command shell, but even then it might be a trick to give that shell a "Console" for you to input in (in windows it would open up a new window). Something like what you said MIGHT work if you piped the user input/output to the app stdin/out, but I bet some linux guru knows a better way. Problem is that "Groovy" owns the console allocated to user I/O. If you could put groovy in the background (equivilent of ctrl-z) or switch to another console (perhaps using Screen or Linux's multiple consoles) you might be able to pull it off, but I probably wouldn't try

Categories : Groovy

Page switching algorithm from Nano editor
I found solution (this._offset is set by this._view) var offset = this._offset + this._rows - cursor_offset; if (y-this._offset >= this._rows) { cursor_y = y - offset; if (this._offset !== offset) { this._pointer.x = x; this._pointer.y = y; this._view(offset); } } else if (y-this._offset < 0) { var new_offset = this._offset - this._rows + cursor_offset; this._pointer.x = x; this._pointer.y = y; this._view(new_offset); cursor_y = y - new_offset; } else { cursor_y = y - offset + cursor_offset + 1; }

Categories : Javascript

Rubymotion query using Nano-Store In Motion
If your loop is trying to print the first names of the children in your array, try this: 0.upto(count - 1) do |c| p child[c].first_name end Alternatively, you could skip the count altogether: child.each do |achild| p achild.first_name end

Categories : Ruby

Storing UIImage in Nano Store In Motion
This may be of benefit: How can I store a UIImage in an NSDictionary? RubyMotion-ized: dict = NSMutableDictionary.dictionaryWithCapacity(1) img = UIImage.imageNamed("whatever") dict["some_key"] = img extracted_image = dict["some_key"]

Categories : Ruby

Add Column to CSV Windows PowerShell
Here's one way to do that using Calculated Properties: Import-Csv file.csv | Select-Object *,@{Name='column3';Expression={'setvalue'}} | Export-Csv file.csv -NoTypeInformation You can find more on calculated properties here: http://technet.microsoft.com/en-us/library/ff730948.aspx. In a nutshell, you import the file, pipe the content to the Select-Object cmdlet, select all exiting properties (e.g '*') then add a new one.

Categories : Powershell

Windows SDK environment and powershell
You can launch an instance of CMD.EXE, run SetEnv.cmd, and then launch PowerShell from within the CMD window. The PowerShell instance that opens up will import the environment variables from the CMD instance that spawned it. It's ugly, but it works. I wrote a batch script to do it for me, and just created a shortcut to it on my desktop. Here's an example: @echo off call "C:PathToSetEnv.cmd" param1 param2 param3 powershell.exe -noexit

Categories : Windows

Launch nano editor passing piped command
Use process substitution: nano <(cat /var/log/qmail/current | tai64nlocal) Also, you don't need to use cat nano <(tai64nlocal < /var/log/qmail/current)

Categories : Linux

How can I set IIS Windows Auth Providers with powershell?
You can only enable and disable the authentication methods available under the following section: system.webServer/authentication This is because system.webServer/authentication is not a collection and does not support the add and remove config elements. Have a look in the IIS configuration schema file in: C:WindowsSystem32inetsrvconfigschemaIIS_schema.xml Search for system.webServer/security/authentication and you will see that each child element of that section is explicitly defined and there is no definition for system.webServer/security/authentication itself. With regards to ordering, it makes no difference trying to change the authentication method order. For example in the following order (Basic is before Windows Authenticaton): <system.webServer> <security

Categories : Powershell

Sending mail with Powershell Windows 7
This could be due to many reasons, but one issue that I had seen this exact same error was because an anti-virus program was blocking Powershell from sending the email. Check if this is the case by looking at your anti virus logs. Beyond that, you might want to check if firewall is fine, you can connect to the SMTP server etc.

Categories : Email

Closing All Explorer Windows in PowerShell
I think there's something in the pipeline that goes wrong. This code works: $a = (New-Object -comObject Shell.Application).Windows() | ? { $_.FullName -ne $null} | ? { $_.FullName.toLower().Endswith('explorer.exe') } $a | % { $_.Quit() }

Categories : Powershell

Why does C# Powershell method work in Windows app but not Web app
You should note that when you do create a profile, it can be user or machine specific. Also, it can be scoped for all shells or just powershell. http://technet.microsoft.com/en-us/magazine/2008.10.windowspowershell.aspx

Categories : C#

Generating Powershell scripts by working in Windows GUI
I don't have the exact answer to your question, but the things you may have read/heard about on some blog or podcast are : first : The Start-Transcript and Stop-Transcrip CmdLets that allow you to record all the command lines you type at the PowerShell prompt. Second : As you are using PowerShell 3 you are using ISE which is now, a not so bas PowerShell editor. But it was not so at the begining and I was using a free editor from Quest Software called PowerGUI. When you download this editor it comes with an other soft called administrative console. This administrative console allow you generate PowerShell for basic operations and comes with a WMI browser that also generate PowerShell scripts. Third : It exists also a PowerShell Scriptomatic, but I just never use it.

Categories : Powershell

PowerShell/Windows scripting: Get interface name containing a specified gateway IP
maybe you can use InterfaceIndex to link this objects: get-wmiObject -Query "select InterfaceIndex from Win32_NetworkAdapter" get-wmiObject -Query "select InterfaceIndex from Win32_NetworkAdapterConfiguration" InterfaceIndex Data type: sint32 Access type: Read/write IP address of the next hop of this route. The value in this property is the same as the value in the InterfaceIndex property in the instances of Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration that represent the network interface of the next hop of the route. In the case of a route bound to an interface that is realized using a broadcast medium, the value of this field is the agent IP address on that interface. description from: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394162(v=vs.85).aspx someth

Categories : Misc

setting NTP server on Windows machine using PowerShell
From a bit of googling about w32tm vs control panel date/time, I found this, which appears to be what you need. Hope that helps you out :-)

Categories : Powershell

Windows Azure Powershell Copying file to VM
You cannot use PowerShell to copy a file directly to a Virtual Machine's OS disk (or even to one of its attached disks). There's no API for communicating directly with a Virtual Machine's innards (you'd need to create your own custom service for that. You can use PowerShell to upload a file to a Blob, with Set-AzureStorageBlobContent. At that point, you could notify your running app (possibly with a Queue message?) on your Virtual Machine that there's a file waiting for it to process. And the processing could be as simple as copying the file down to the VM's local disk.

Categories : Powershell

Simple way to get CPU load from Windows Server via PowerShell
Assuming the $Servers collection to be populated with host names, you are not that far off. I don't have the Quest tools, so am unable to check the collection. # Best practice: avoid mistyped variable names set-psdebug -strict $Servers = Get-QADComputer -sizelimit 0 | where {$_.Name -like "*myserver*"} | select Name # Best practice: avoid magic numbers; readonly variable for new-variable -name CPULIMIT -value 75 -option readonly foreach($Server in $Servers){ $result = Get-WmiObject win32_processor -ComputerName $Server.Name # TODO: add error handler here in case $server is unavailable # Compare the wmi query result to the limit constant if($result.LoadPercentage -le $CPULIMIT){ # Write a formatted string that contains the server name and current load Writ

Categories : Powershell

Running PowerShell script in a C# Windows Service App
Here is a pretty good discussion on how to call Powershell from C#: http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C I suggest you start with the RunScript function and add it to a VS2010 console application. Main() would then invoke RunScript something like RunScript( "echo 'hello from PS';get-date; get-culture; "). Windows services have quite a few differences from a normal console application. You can read about how to write a windows service on MSDN, but if you've never coded before, you have a steep learning curve in front of you. There is a service from an old Resource Kit call srvany.exe (Google it) which would run any console app as a service. However in Windows Vista (and above) services were restricted from accessing the desktop, so srvany could

Categories : C#

Get-ScheduledTask in PowerShell on Windows Server 2003
You'll find all the informations you need about the missing COM object in Working with scheduled tasks from Windows PowerShell. Using Windows Server 2012 you can use Scheduled Tasks Cmdlets in Windows PowerShell.

Categories : Powershell

Powershell remoting: Cannot connect to Windows 2012 EC2 Instance
First you need to sort out if a connection can be established to the remote machine. Easiest is to try the following command from the windows command prompt: telnet <ip> 5985 If the telnet client is not installed, add it via add/remove windows components. If a connection is not possible, you will get an error. This is the most likely error. Possible reasons: Client side firewall (local or network) preventing the connection EC2 Security group configuration Server firewall rule. Since you can access the remote machine over remote desktop, run the same command on the server to make sure that the WinRM service is actually working and listening on the default port. If a connection is possible from the client machine, open the event viewer on the server and go to: "Applications and

Categories : Windows

Windows Powershell - Cannot create a html table correctly
I too suspect it's related to how you're building the custom object within the foreach-object loop; after playing a while I gave up and tried to build it from scratch. Hopefully this will work for you. Before your Get-ChildItem call create an empty array: $tableObject = @() Then change your foreach-object block to fill the array iteratively with the contents of the psobject: ForEach-Object { $properties = "" | Select Directory, Name, DateModified $properties.Directory = $_.Directory $properties.Name = $_.Name $properties.DateModified = $_.LastWriteTime $tableObject += $properties } Finally, outside of the foreach-object block add the table, passing the array without having to select anything: $script:M

Categories : Windows

Git GUI/TortoiseGit Not calling hooks that use powershell correctly? (Windows)
I think I saw this happen once before. The ExecutionPolicy is different when in an interactive shell vs a shell spawned by a script. Try this: c:/windows/system32/WindowsPowerShell/v1.0/PowerShell.exe -ExecutionPolicy:Bypass -Command "New-Item File.txt -type file"

Categories : GIT

Error While uploading to windows Azure using powershell Script
I moved my script to the virtual machine which is hosted on azure and this error is no more so i think this error was due to my firewall or due to the slow internet connection.the script is running as desired on the virtual machine and i am able to automate my deployment process.

Categories : Asp Net

Find unique/distinct files in windows powershell.
cd c:Folder ls | ? { -not $_.PSIsContainer -and $_.BaseName -cmatch 'Esd{2}' } | % { $folder = $matches[0] new-item -ItemType Directory -Path . -Name $folder -ErrorAction SilentlyContinue move-item $_.Name $folder } Idk if this helps, but I suggest more research. If you were talking about just doing ls | ? {$_.Name -cmatch "Esd{2}"} | select unique That might not be very useful

Categories : Sorting

How can you close a specific Windows comObject by a trait like location name? Powershell
Figured it out.. (New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationURL -eq "File:///C:/Scripts/Whatever/Folder/Path"} | foreach-object {$_.quit()} In case anyone else is dumb like me :)

Categories : Windows

Windows Powershell - Returning and supplying variables to functions does not work
In your do-while look, $MyReport is just passed to the print everything method. But, it will not be in scope at that point as you are just assigning to $MyReport within the functions. Try using $MyReport as $script:MyReport everywhere, so that it will be in script scope. This is not the ideal solution, but should be good enough to get you started. Also, you might want to read up on pipeline / function output in powershell. You are using it wrong - http://stacktoheap.com/blog/2013/06/15/things-that-trip-newbies-in-powershell-pipeline-output/

Categories : Function

Trouble creating multiple folders from a TXT file in Windows PowerShell or CMD?
The "workaround" for the "`Set-ExecutionPolicy error'" is to set the execution policy to allow scripts to run. See http://technet.microsoft.com/en-us/library/ee176961.aspx . It's set to the most restrictive by default but any admin worth his salt will set it to something less restrictive based on what the environment requires. Once you've done that, your script looks solid.

Categories : Windows

Installing Windows Features on remote server 2012 using powershell 3.0
Personally I would use the latter (directly call Install-WindowsFeature -ComputerName $server rather than do a separate Invoke-Command) in this case for the following reasons: You may be hard-coding the feature names now, but in the future you may want to put those in a variable. If you put them in a variable, you'll have to pass it as a parameter into the Invoke-Command's script block. This is entirely possible, but more work. By using your own loop, you can write progress messages, logging, etc. You gain nothing by using Invoke-Command in this case because you're running a single command on the remote computer (as opposed to running multiple commands with -ComputerName parameters vs. running multiple commands inside the script block).

Categories : Powershell

Can I control Windows 7 Task Scheduler conditions with Powershell Script?
Check out this blog, http://www.vinithmenon.com/2012/11/powershell-v3-scheduled-job-to-start.html, it has steps on how to use scheduled tasks module in powershell, you would need to get powershell V3

Categories : Powershell

powershell 'system.windows.media.mediaplayer' Register-ObjectEvent
Add-Type -AssemblyName PresentationCore $_MediaPlayer = New-Object System.Windows.Media.MediaPlayer $_MusicFolder = 'C:UsersMaking JESUS ProudMusic' $_MusicFiles = Get-ChildItem -path $_MusicFolder -include *.mp3 -recurse $duration = $null foreach($_file in $_MusicFiles){ "Playing $($_file.BaseName)" [uri]$_song = $_file.FullName do { $_MediaPlayer.Open($_song) $_songDuration = $_MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds } until ($_songDuration) $_MediaPlayer.Volume = 1 $_MediaPlayer.Play() Start-Sleep -Milliseconds $_songDuration $_MediaPlayer.Stop() $_MediaPlayer.Close() }

Categories : Powershell

How do I grant SeBatchLogon privileges to a domain account on a Windows server with Powershell?
Use ntrights.exe from the Windows Server 2003 Resource Kit Tools: ntrights +r SeBatchLogon -u mydomainatchuser

Categories : Powershell

Gather [System.Windows.Forms.Screen]::AllScreens via Powershell remotely
No, this is not possible. Screen.AllScreens does not have a remote version so you need to use PowerShell remoting to call that method on a remote machine. If you use PowerShell remoting you end up in a PowerShell Windows Service which has a default desktop. This desktop is not visible, belongs to the system account and has no real screens. Therefore it will simply not give you the result you want. Also see here.

Categories : Powershell



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.